Enough chitchat. Lets see your bubble sort

>Enough chitchat. Lets see your bubble sort.
How do you respond?

Other urls found in this thread:

stackoverflow.com/questions/895371/bubble-sort-homework
youtube.com/watch?v=kPRA0W1kECg
twitter.com/NSFWRedditVideo

Okay gimme 2 minutes

No u

You have no place in the tech industry if you can't do a bubble sort. I'm sorry but it's just not for you. Meritocracy holds technology together.

Bubble sort? Really? Not even simple O(n*log n) sort? Fine though, you want it in pseudo code or in some particular language?

randomize all entries
check if they're in order
goto 10

And yet many senior developers can't even do bubble sort off the top of their head, much less sum the primes below 2 million. Ruby on Rails creator comes to mind (quoted as saying "Hello, my name is David. I would fail to sum all primes below 2 million on a whiteboard. I look code up on the internet all the time. I don't do math.").

I hit the person in the face, flip the table and run.

h-haha y-you must be ... k-kidding me!

rate

I would just use a single qsort call.

I got fired from my last job because I suggested a faster sorting algorithm than my boss'. As in, how dare I know more than him.

B O G O
O
G
O

import bubblesort
bubblesort.sort(x)

YES
E
S

Why is this frowned upon again?

toplel

i don't remember which sort is bubblesort

kek

i haven't used bubble sort since first year 7 years ago but it was super easy reasoning it out mentally in like a minute or 2

you're prob awful if you can't

>Why is this frowned upon again?
Because suppose you need to implement a more complex algorithm and have it be efficient, then it's not enough to use semi-random functions and generators hoping it'll stick. You need to understand basic maths, which includes algorithms.

I don't even program and I know how to "bubble" sort. Literally takes one gif to learn.

>Yeah he seemed very capable, but he thinks he's smarter than he is...
0% hire

this

I don't see an implementation in your post, just baseless words. Back it up, or else.

for (int i = 0; i < n; i++) {
for (int j = 1; j < (n - i); j++) {

if (numArray[j - 1] > numArray[j]) {
temp = numArray[j - 1];
numArray[j - 1] = numArray[j];
numArray[j] = temp;
}

}
}

Posting here. People might be interested

Ok I'll admit I didn't know which sort exactly bubble sort was. That shit is piss easy to implement, but do interviewers actually expect you to know how to implement some random sorting algorithm?

What's a bubble sort?

Oh, so bubble sort takes an array/list, goes from the bottom to the top looking for the shortest (or lowest number or letter etc) and moves it to the top and does this repeatedly until it is in order.

"Theoretical, or practical?"

var bubblesort = require('bubblesort');


Where do you work where anyone writes performant code? Every time I point out to someone how to improve performance with a sorting algorithm they just say "Yeah that was on my list of things to do" and they never do it.

Yeah that'll get you hired

Welcome to the team!

my bubblesort is too fast for you traveller

lol bye

How about I show you my Sleep Sort?

Only autistic assholes think having sorting algorithms retained to memory are useful.

It takes about 20 seconds to look up the implementation.

function f() {sleep "$1" echo "$1"}
while [ -n "$1" ] do f "$1" & shift done wait
when do i start?

It's a sorting algorithm where it takes something, and swaps it around until it finds something bigger, and then takes that & repeats the processes until everything is sorted. It's not the best sorting algorithm, but it works. It's also called sinking or sink sort because bigger or smaller pieces "sink" to the bottom as you sort.

wew lad

>alright, let me just google that first

>maths
fuck off reddit

Sorry, I'm not bubblepilled. Can you give me a quick rundown?

this, maths is gramatically incorrect

>quick
>quick3
>merge

whats the difference?

>write it in Forth or APL
Oh didn't they teach you this at your meme school, "BOSS?"

/drops dry erase pen

Call me if you need a real programmer. I charge $500 an hour.

Webdev here, making 120k. I couldn't bubble sort or fizzbuzz to save my life. We leave that to the Pajeets :)

So you do the photoshop, illustrator and wordpress?

(defun bubble-sort-vector (vector predicate &aux (len (1- (length vector))))
(do ((swapped t)) ((not swapped) vector)
(setf swapped nil)
(do ((i (min 0 len) (1+ i))) ((eql i len))
(when (funcall predicate (aref vector (1+ i)) (aref vector i))
(rotatef (aref vector i) (aref vector (1+ i)))
(setf swapped t)))))

(defun bubble-sort-list (list predicate)
(do ((swapped t)) ((not swapped) list)
(setf swapped nil)
(do ((list list (rest list))) ((endp (rest list)))
(when (funcall predicate (second list) (first list))
(rotatef (first list) (second list))
(setf swapped t)))))

(defun bubble-sort (sequence predicate)
(etypecase sequence
(list (bubble-sort-list sequence predicate))
(vector (bubble-sort-vector sequence predicate))))

got it wrong

Stop oprrssing me you fucking white males

WHO GIVES A FUCK ABOUT A COMPARISON SORT
IF YOU DONT USE RADIX YOU ARE LITERALLY MICROCEPHALIC

This is quickly becoming a template thread.

start at beginnig of ar aray.
is next element bigger?
if so swap bothe indexes
repeat till sorted.

I bet if you wrote selection sort they wouldn't care

quick = choose 1 pivot, usually last element
quick 3 = choose 3 pivots, take median one
merge = I don't know if you're trolling or not...

Maths is what we say in England, faggot
Invent your own language

Even in England it is incorrect, it's just slang.

So is physics wrong too

...

Wasn't this guy arrested or some shit?

I love this picture and knowing that he probably said it in heavy ebonics and they had to make it sound proper when they typed it up.

...

I write either bubblesort or minmax sort because I'm shit at programming and everything inbetween and can't differentiate the sorts that I've used

ok, here is mine.
def sort(num)
i = 0
while i < num.size
j = num.size - 1
while i < j
if num[j] < num[j - 1]
temp = num[j]
num[j] = num[j - 1]
num[j - 1] = temp
end
j -=1
end
i +=1
end
return num
end

Ruby, pass an array of unsorted numbers to the method sort.

I didnt test this code, but have been learning sorting algorithms lately so this should be ok.

pls no bulli
n = '1593746820'
count=0
end=None
while True:
if n[count:2+count][0] > n[count:2+count][1]:
n = n[:count]+n[count:2+count][1]+n[count:2+count][0]+n[2+count:]
print(n)
count+=1
if count == len(n)-1:
count=0
if n == end:
print('done')
break
else:
end = n

Ugh. How about I show you my selection sort?
R E A D A B L E C O D E

I mean school text books have the words 'maths' written on them but sure it's just slang.

source?

(define (bubble-sort! array less)
(define* (pass! array less #:optional (start 0) (sorted #t))
(if (>= start (- (array-length array) 1))
sorted
(let ((first (array-ref array start))
(second (array-ref array (+ start 1))))
(if (less second first)
(begin (array-set! array second start)
(array-set! array first (+ start 1))
(set! sorted #f)))
(pass! array less (+ start 1) sorted))))
(while (not (pass! array less 0)) continue)
array)

But this is for a chemistry job.

Bubble sort is one of those algorithms you learn about 1st semester and then you never use it because there is always better way.

here is my shot though:
for(size_t i = container.size() - 1; i != 0; --i)
for(size_t j = 0; j != i; ++j)
if(container[j] > container[j + 1])
swap(container[j], container[j + 1]);

That's not bubble sort.

for(i = 0; i < sizeof(arr);i = i + 1) {
arr[i] = i + 1;
}

>How do you respond?
Pull out my bubble blower and start blowing bubbles.
Use gentle breaths to sort them in decreasing size order.

>1 sec
>*pulls out phone*
>here
stackoverflow.com/questions/895371/bubble-sort-homework

*writes selection sort*

array.sort { |l.r| l r }

> job interview coming up
> gotta practice
> do some coding at home but mostly just shitpost
> the day arrives
> go into the building
> they send me into a room
> boss comes
> he asks me to come up with an algorithm, check his printed algorithm
> I fuck up
> "It does not matter, we are looking for good people, you will learn the rest anyway."
> got the job

tl;dr: No one gives a flying fuck about your bubble sort.
You can Bubble Fuck Yourself with it.

> inb4 got lucky
> inb4 only one workplace

Nope I have been into several bigger places (military contractor, GE, etc). No one cares about Fizz Buzz and shit like that. They ask some general questions about the language, ask your experience, but nothing extra. If you are not a fucktard they will hire you.

oh cool, thanks

In UK you literally learn bubble sort at 16, maybe even 15.
Are you people telling me Amerilard computer "scientists" have trouble grasping bubble sort at 25?

If you can figyre out, you get your diploma instantly.

How the fuck can you not sum the primes below two million? It's so fucking easy it's absurd.

If I were an employer, you wouldn't catch a single employee of mine unable to implement fizzbuzz, summation of primes, or bubble sort. It's not an inability to do intense math or theory, it's an ability to use your fucking head.

Fuck I actually cheated my way through that part in java with Algorithms

I'm so sorry :( I can't do this

Oh I'm an idiot
So this thread is itonic?

C...can I have access to Rosetta Code plz

It's from The Onion you fuckwits.

"nobody cares" except the places that do care.

I once did a week long interview, consisting of 45min whiteboard interviews for 5 days straight each time with a different group of 'engineers' trying to trick me or get me to implement some kind of algorithm.

"Hey user so us a way to do the fastest division"
"How can we optimize this?"
"Can we optimize this some more?"

That's all you do. Write algorithm, optimize a few times all the time while reasoning aloud

youtube.com/watch?v=kPRA0W1kECg

If you enjoy sorting algorithms but also space noises.

> O((n!)!)

>Bubble sort even sounds like bubbles
Clearly the patrician sort

to be honest the Sieve of Erastothenes is not really intuitive, you have to have learned it somewhere

Stand up and leave. This is disrespectful.
>Ok so you had all these projects that are relevant to us that's nice, and you did that and you did this
>Now please look at this picture and tell us where is the square here and where is the triangle
>And what is the name of this letter?
>Good boy, very good

>so user, write me a function that takes an average of two numbers
wat do?

>Collection.sort(Collection)
>This is more efficient than bubblesort

w-when do i start?

Only good solution ITT. Morons make everything from scratch, a thinker builds on the work of others.