a software engineering interview question I like: computing the median

50 points by sunflowerseastar


vrolfs

I don't really understand this post. I think the author is not aware that the median can be computed in O(n). See here: https://rcoh.me/posts/linear-time-median-finding/

So this is wrong:

Right out the gate: the numbers must be sorted.

For this reason, it's not really such a great interview question, since the optimal solution is a complicated algorithm that nobody can be expected to produce quickly on the spot (unless they know it by heart, which is also not helpful for testing the candidate).

I guess you could ask the candidate to produce the "naive" solution (using some library function to sort the array, then return the middle).