4 ms·
Will 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 wi
by mason55 14y ago
Will 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.