make a max-heap of size 1 million and insert the first 1 million numbers in it for each new number from hard disk compare it to the maximum element of the heap if it's bigger than max check next element else extract-max from heap and insert the new element
the running time would be 1 trillion x log (1 million ) On 6/23/10, amit <[email protected]> wrote: > Given a set of 1 Trillion integers on hard disk, find the smallest 1 > million of them. You can fit at most 1 million integers in memory at a > time. State the fastest solution you can think of. > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
