Similar to selection searching problem. On Mon, Jul 11, 2011 at 4:37 PM, abhijith reddy <[email protected]>wrote:
> Wouldn't a heap be ideal for this ? > > > On Mon, Jul 11, 2011 at 3:35 PM, John Reid <[email protected]>wrote: > >> I have a procedure that generates N x M values sequentially. I want to >> store the N largest ones and discard the others. Obviously I can store all >> the values in a vector, sort it when it is full and then choose the top N >> values. Is there a more efficient way using a data structure that just >> stores the top N values as the procedure goes along? Typically M is 1,000 >> and N is anywhere from 1,000 to 50,000. I have no prior expectation on how >> the N largest values are distributed amongst the N x M values. >> >> I'm working in C++ with the STL and boost libraries. >> >> Thanks for reading this, >> John. >> >> -- >> 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 algogeeks+unsubscribe@** >> googlegroups.com <algogeeks%[email protected]>. >> For more options, visit this group at http://groups.google.com/** >> group/algogeeks?hl=en <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. > -- Saurabh Singh B.Tech (Computer Science) MNNIT ALLAHABAD -- 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.
