Hacker News new | ask | show | jobs
by mrits 2039 days ago
Googling how to bubble sort seems a bit extreme. I'm not much for Cracking the Code Interview type questions but this would certainly be a red flag.
8 comments

I'd have to google "bubble sort" to even remember what it is; but I don't think that has any bearing on whether I'd understand it once I remembered what it was.
I'd tell you what it is in an interview if you asked. The author knows what it is but needs to google an implementation.
Part of the problem with things like "implement Bubble Sort" is that most actual programming tasks are "here's a problem, find the best implementation". There aren't many sorting tasks where Bubble Sort is an appropriate implementation: a _better_ interview question would be "here's a list of numbers, sort them without using a standard library function." Followed by "what are some advantages/disadvantages of the method you used? Can you think of a better way to do this?"
That isn't a bad interview question but certainly not _better_. It's perfectly understandable for some shops to want to filter out people that don't practice fundamentals from time to time. We all have our own predictors of success and they all suck in different ways.
FizzBuzz also has zero practical value, yet it will filter out people who can't code.
But, the question is formulated like a normal programming task: it's not "implement this algorithm" it's "come up with a program that removes numbers that meet this specification".
You wouldn't get this question even in that style of interview. Besides bubblesort just being terrible for everything, you don't get many "implement X" questions even in coding style interviews, they just don't make for good questions.

Questions need to be in pursuit of some goal, with different options for implementation. Usually you'll get a question with a fairly simple naive implementation with terrible performance, then other options which have more favorable worst case running time.

I’ve been a programmer or otherwise involved with software since roughly 1998 and never had to write a bubble sort at work. Why would googling it be a red flag?

It might be surprising to the hackernews crew but 98% of software jobs have nothing in common with leetcode problems. Most people are writing Java, c#, JavaScript etc and using the built in data structures and doing list.Sort() or something similar.

I've never had to do a bubble sort outside of college/uni. You could ask me right now to do one and I wouldn't be able to do it without at least having the steps in written English.

I've never needed to use one, I can just do .OrderBy() or similar in the language I use.

Does that make me a bad developer?

I have never needed to implement a sorting algorithm, so time spent memorizing them would be pretty wasteful compared to learning something useful.

I do remember Barack Obama advising against bubble sort though.

A lot of people would google FizzBuzz unfortunately.
I'm about to do some interviewing and I am much more interested in how they would handle a credit card provider being down when processing a transaction. Or if they can articulate that solution verbally. Or if they handle me taking an opposite position as devil's advocate well, etc.
Using a resilience library like Polly, if the transaction still fails after a few attempts then handle it according to business requirements.

https://github.com/App-vNext/Polly

Absolutely. You want both but I would also value what you’re talking about a lot more.
IIRC, bubble sort is only useful if you're sorting a doubly linked list in constant memory. Linked lists aren't that useful either. If you're iterating over the entire list and making changes in the middle, you're better off rebuilding the list as a vector because lower memory overhead makes two vectors smaller than one linked list. The most frequent correct uses of linked lists that I've seen are lock-free, concurrent data structures and hashtables that save insertion order.