4 ms·
We use bubble sort as a kind of FizzBuzz test. Sorry, but we have to verify that you can actually write code. We can't go further without it.
by guard-of-terra 14y ago
We use bubble sort as a kind of FizzBuzz test.
Sorry, but we have to verify that you can actually write code. We can't go further without it.
- mason55 14y agoWill you provide the bubble sort algorithm if asked? The first comment on this post also says they ask search questions as a FizzBuzz filter, but unless you will provide the algorithm then you're also asking it as an algorithms question.
- tptacek 14y agoYou can't do bubble sort off the top of your head?
- tsuraan 14y agoI'm not honestly sure I can. I can certainly do merge sort and a really naive quicksort, but bubblesort's not something I've ever written, nor have I even seen a description of the algorithm since my freshmen year of college or earlier. The name isn't exactly descriptive, so if I were asked to implement it I'd probably take my best stab at it and wind up implementing some other O(n^2) sort. Does that make me a bad programmer?
- tptacek 14y agoIf you can do any real sort algorithm in real code off the top your head, bubble sort shouldn't matter, and any interviewer who punts you for that is interviewing for a job you don't want.
- sbov 14y agoI can do insertion sort off the top of my head, because I find it very intuitive. Bubble sort always seemed odd to me, and since I can remember insertion sort, if I ever found myself in the odd position of having to write a sort for a program without any reference materials, I'd just use insertion instead.
- phaylon 14y agoFrom looking it up on Wikipedia I found out that I would've remembered it, but it was around 15 years ago that I last wrote one myself. So I would've had to ask if it was the one where you iterate over the values and keep the largest, then repeat. I've learned these at the same time as the other generally known sorting algorithms, so names and details are quite fuzzy. It probably depends on the position. As a high-level language developer I don't usually implement my own sorting algorithms. Either I use prebuilt libraries that offload work to low-level, or I use builtins, or I ask the database to sort it for me :)
- guard-of-terra 14y agoYes we would. I always wonder what to do when I receive three identical follow-ups. Answer three times?
- m0nastic 14y agoIf still within the window, you could just add an "edited:" to your comment including that information.
- guard-of-terra 14y agoNobody will be notified of my edit.
- m0nastic 14y agoright, but you can at least hopefully prevent other people from asking. Comment Triage.
- tocomment 14y agoOk who here over five years out of school remembers bubble sort? Give me the Wikipedia article and I could code it in five minutes but I just don't remember the specifics of the algorithm. Does that really make me a bad hire?
- guard-of-terra 14y agoOf course we will tell you how it is supposed to work.
- tocomment 14y agoOk you're cool then :-).
- wglb 14y agoI do, and school was a frighteningly long time ago. As a clue, I think the last language I coded it in was Fortran II.
- mgkimsal 14y agoThat's somewhat odd... I've worked at some big companies and some small companies, and have never, ever been asked to code a bubble sort, either in interviews nor has it ever come up in production. Ever. I've been doing this professionally for coming up to 20 years (full-time professionally for 17, part-time before that). I'd possibly fail your interview. I wonder how I've survived in software development this long. That's not a snarky question either.