4 ms·
Sorting algorithms in general aren't constants, though. The implementation can have significant impact on running time, memory use, etc. And there are an infi
by Groxx 13y ago
Sorting algorithms in general aren't constants, though. The implementation can have significant impact on running time, memory use, etc. And there are an infinite number of them with various tradeoffs you can tune.
I wouldn't expect an interviewee to know sorting algorithm X because they may just have forgotten. But why wouldn't they be able to come up with a sorting algorithm, and have some feel for the behavior? Seriously, selection sort is about as easy to come up with as fizzbuzz. If they can't think through a simple problem and come up with a solution, is it wrong to question their problem-solving skills?
- eli_gottlieb 13y agoActually, if you asked in an interview how to sort, I'd try to come up with quicksort or mergesort. I wouldn't give you insertion sort or selection sort because I'd feel terminally embarrassed to go with so bad an answer.
- Groxx 13y agoIs it terminally embarrassing to say "this is bad, but..." and pass the test, then discuss (maybe write out) more advanced options? If all they care about is selection sort, you've saved time (often a good quality). If they care about more, you've demonstrated something, and opened the door for more.
- eli_gottlieb 13y agoDepends. I've been in interviews where they let me damn well know I was losing points for giving an algorithmically sub-optimal answer.
- Groxx 13y agoSounds like (a) fun interview(s) :/ Alas, they exist. I guess it's too much to hope they don't.