So xkcd had a delightful comic a few days ago about Ineffective Sorts (and below), and it really struck a chord with me. I’ve often hear of people being asked to (pseudo)code quicksort, or something similar, during an interview. This really irks me. If on the job a boss says, “Quickly Josh, we need a quicksort!!”, the last thing I’m gonna do is sit down and stare at a page of pseudo-code riddled with off-by-one errors. Nor am I very likely to go back to the textbooks and look it up (a much safer option anyway). Am I really being hired to reimplement STL or Boost libraries? Because those guys look like they got this stuff pretty darn well. And its super tested.
But you, my avid reader, protest “it’s a test to see how you think and reason”. Okay that’s fair, but I, for the sake of discussion, claim quicksort and other standard algorithms aren’t the right way to test an applicant’s reasoning ability. All applicants know quicksort could be asked, so we all look it up. Now, when we are sitting down during an interview, we’re trying to recall all the intricacies of a mature algorithm. Instead of reasoning through divide-and-conquer, I’m thinking “oh crap, now how to I pick the pivot to avoid those QS-attacks?”. I’m trying to remember how to get all the details right, when I should be iteratively addressing problems as they arrive.
Of course, if you’re hiring someone to squeeze out the next 1% of execution time in some DB-query, then absolutely he or she should know every damn intricacy of the standard algorithms. But for the rest of us, I think non-standard brain teasers or puzzles seem much better than reproducing a well-known mature algorithm.