[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

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

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 95
Thread images: 11

>Enough chitchat. Lets see your bubble sort.
How do you respond?
>>
>>59678004
Okay gimme 2 minutes
>>
>>59678004
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.
>>
>>59678004
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
>>
>>59678082
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.").
>>
>>59678004
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.
>>
>>59678168
B O G O
O
G
O
>>
import bubblesort
bubblesort.sort(x)
>>
>>59678659
YES
E
S

Why is this frowned upon again?
>>
>>59678659
toplel
>>
i don't remember which sort is bubblesort
>>
>>59678659
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
>>
>>59678775
>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.
>>
>>59678141
>Yeah he seemed very capable, but he thinks he's smarter than he is...
0% hire
>>
>>59678168
this
>>
>>59679023
>>59679057
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;
}

}
}
>>
File: 1466086847922.webm (214KB, 900x456px) Image search: [Google]
1466086847922.webm
214KB, 900x456px
Posting here. People might be interested
>>
>>59679049
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?
>>
>>59678004
What's a bubble sort?
>>
>>59679147
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.
>>
>>59678004

"Theoretical, or practical?"
>>
>>59678004
var bubblesort = require('bubblesort');


>>59678082
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.
>>
>>59678168
Yeah that'll get you hired
>>
>>59678659
Welcome to the team!
>>
>>59678004
my bubblesort is too fast for you traveller
>>
>>59678004
lol bye
>>
How about I show you my Sleep Sort?
>>
>>59679049
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?
>>
>>59680755
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.
>>
>>59678659
wew lad
>>
>>59678004
>alright, let me just google that first
>>
>>59679049
>maths
fuck off reddit
>>
Sorry, I'm not bubblepilled. Can you give me a quick rundown?
>>
>>59681801
this, maths is gramatically incorrect
>>
File: 4.jpg (51KB, 600x800px) Image search: [Google]
4.jpg
51KB, 600x800px
>>59679147

>quick
>quick3
>merge

whats the difference?
>>
>>59678004
>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.
>>
>>59678082
Webdev here, making 120k. I couldn't bubble sort or fizzbuzz to save my life. We leave that to the Pajeets :)
>>
>>59683123
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))))
>>
>>59679123
got it wrong
>>
Stop oprrssing me you fucking white males
>>
>>59678004
WHO GIVES A FUCK ABOUT A COMPARISON SORT
IF YOU DONT USE RADIX YOU ARE LITERALLY MICROCEPHALIC
>>
>>59678004
This is quickly becoming a template thread.
>>
>>59678004
start at beginnig of ar aray.
is next element bigger?
if so swap bothe indexes
repeat till sorted.
>>
>>59679418
I bet if you wrote selection sort they wouldn't care
>>
>>59682335
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...
>>
File: FB_IMG_1490465641172.jpg (123KB, 1080x1069px) Image search: [Google]
FB_IMG_1490465641172.jpg
123KB, 1080x1069px
>>59681855
Maths is what we say in England, faggot
Invent your own language
>>
>>59683474
Even in England it is incorrect, it's just slang.
>>
>>59683943
So is physics wrong too
>>
File: racistcomputers.jpg (22KB, 450x200px) Image search: [Google]
racistcomputers.jpg
22KB, 450x200px
>>59678004
>>
>>59683987
Wasn't this guy arrested or some shit?
>>
>>59683987
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.
>>
File: 947813-fs8.png (63KB, 460x432px) Image search: [Google]
947813-fs8.png
63KB, 460x432px
>>59683987
>>59684049
>>59684453
>>
>>59678004
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
>>
File: rubyist.jpg (18KB, 260x325px) Image search: [Google]
rubyist.jpg
18KB, 260x325px
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
>>
>>59683943
I mean school text books have the words 'maths' written on them but sure it's just slang.
>>
>>59678191
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.
>>
>>59678082
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]);
>>
>>59685320
That's not bubble sort.
>>
for(i = 0; i < sizeof(arr);i = i + 1) {
arr[i] = i + 1;
}
>>
>>59678004
>How do you respond?
Pull out my bubble blower and start blowing bubbles.
Use gentle breaths to sort them in decreasing size order.
>>
>>59678004
>1 sec
>*pulls out phone*
>here
http://stackoverflow.com/questions/895371/bubble-sort-homework
>>
>>59678004
*writes selection sort*
>>
File: merchant.jpg (69KB, 501x585px) Image search: [Google]
merchant.jpg
69KB, 501x585px
array.sort { |l.r| l <=> r }
>>
File: 1481899147117.jpg (240KB, 960x720px) Image search: [Google]
1481899147117.jpg
240KB, 960x720px
>>59678082
>>59678004
> 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.
>>
>>59683473
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?
>>
>>59688320
If you can figyre out, you get your diploma instantly.
>>
>>59678191
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.
>>
>>59678004
Fuck I actually cheated my way through that part in java with Algorithms

I'm so sorry :( I can't do this
>>
>>59688429
Oh I'm an idiot
So this thread is itonic?
>>
>>59678004
C...can I have access to Rosetta Code plz
>>
>>59683987
>>59684049
>>59684453
>>59684500
It's from The Onion you fuckwits.
>>
>>59685995
"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 anon 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
>>
>>59679147
https://www.youtube.com/watch?v=kPRA0W1kECg

If you enjoy sorting algorithms but also space noises.
>>
>>59678168
> O((n!)!)
>>
>>59689904
>Bubble sort even sounds like bubbles
Clearly the patrician sort
>>
>>59678004
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 anon, write me a function that takes an average of two numbers
wat do?
>>
>Collection.sort(Collection)
>This is more efficient than bubblesort
>>
File: bubblesort.png (28KB, 855x560px) Image search: [Google]
bubblesort.png
28KB, 855x560px
>>59678004
w-when do i start?
>>
>>59678659
Only good solution ITT. Morons make everything from scratch, a thinker builds on the work of others.
Thread posts: 95
Thread images: 11


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.