|
|
|
|
|
by bnoordhuis
5532 days ago
|
|
> His grandmother knew radix sort. Radix sort? I read it as a trick question where the answer is 'hash table with numberOfYearsOld as the key'. I suggested that as the solution to an almost identical question when interviewing with Google - and it got rejected by the interviewer. Ah, the arbitrariness of it all! |
|
Second, assuming that numberOfYearsOld takes on at most 100 unique values (which I think is reasonable), the best you can hope for is for every hash table insertion and lookup to require you to traverse an average of 5000 students (because on average you will have to look through half of a list of 10,000 students). If you used this as an intermediate step in a real sorting algorithm, your sort would take O(n^2) time.