It would be interesting to do some tests. Asymptotic performance isn't always important. It's possible that since we are looking for only the top 10 elements, we'll get better run times using a simple linear scan to find the insertion point (as in insertion sort) rather than the more complex heapify operation. Log base 2 of ten is 3+, but on average we'd scan only 5 elements for a simple insertion. These are so close that constant factors will make a difference. It's likely that the interviewer was looking for people to notice this.
-- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algoge...@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.