Re: [algogeeks] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-16 Thread Piyush Sinha
Can't we do this using map library function..mapping the integer with their frequency count?? On Sun, May 15, 2011 at 10:15 PM, Dave dave_and_da...@juno.com wrote: @Akshata: Yes. In my response of May 7, I proposed an algorithm using hashing. On May 9, Apoorve asked if there was an in-place

Re: [algogeeks] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-15 Thread Akshata Sharma
hash all the elements. Keys are stored in hashmap in sorted order based on values. just iterate thru the hashmap extracting the first k keys. m I missing something? On Thu, May 12, 2011 at 2:50 AM, Dave dave_and_da...@juno.com wrote: @Apoorve: I don't believe that you can determine the

Re: [algogeeks] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-11 Thread Apoorve Mohan
@Dave: Can there be an in-place O(n) solution to this??? On Mon, May 9, 2011 at 7:01 PM, Dave dave_and_da...@juno.com wrote: @Ashish: By compress, I meant to transfer the active entries in the hash table into contiguous elements of an array. Since the hash table itself is probably stored in

Re: [algogeeks] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-10 Thread Aamir Khan
On Mon, May 9, 2011 at 11:44 AM, Ashish Goel ashg...@gmail.com wrote: Dave, w.r.t statement, After all integers are processed, compress out the unused hash table entries and find the Kth largest element, I could not understand the compress concept...are you saying something on counting

Re: [algogeeks] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-09 Thread Ashish Goel
Dave, w.r.t statement, After all integers are processed, compress out the unused hash table entries and find the Kth largest element, I could not understand the compress concept...are you saying something on counting sort philosophy? say the list is 5 4 4 3 3 3 2 2 2 2 1 1 1 1 1 so the hash

Re: [algogeeks] Re: Extract Top K elements from a List of N elements based on frequency

2011-05-07 Thread Gaurav Aggarwal
ok, i got it.. ya i misunderstood it.. On Sat, May 7, 2011 at 11:03 PM, Dave dave_and_da...@juno.com wrote: @Gaurav: As I understand your solution, you are finding the K largest integers based on value, rather than the K with the highest frequency of occurrence. @Amit: Hash the integers