Re: [algogeeks] Infinite stream , identify distinct k kintegers

2013-06-05 Thread sourabh jain
use a bit vector to mark the existence of the distinct Integer. eg : vector : 00 integer occured : 5 7 9 22 8 vector: 000111101 On Sun, Jun 2, 2013 at 12:57 PM, Avi Dullu wrote: > (For very large k case only) > > Keep as many elements in the hash

Re: [algogeeks] Infinite stream , identify distinct k kintegers

2013-06-05 Thread sourabh singh
for each num instream inserting num to stl::set() if size of set == k break O(nlogk) On Sun, Jun 2, 2013 at 10:49 AM, MAC wrote: > Given an infinite stream of integers with only k distinct integers, find > those distinct integers. How would you modify your solution if k is als

Re: [algogeeks] Infinite stream , identify distinct k kintegers

2013-06-02 Thread Avi Dullu
(For very large k case only) Keep as many elements in the hash_map as you can. Once the map capacity is exhausted, sort all the elements in the hash_map and write them to disk and build a bloom filter. Keep this bloom filterin memory, empty the hash_map a

[algogeeks] Infinite stream , identify distinct k kintegers

2013-06-01 Thread MAC
Given an infinite stream of integers with only k distinct integers, find those distinct integers. How would you modify your solution if k is also very large and cannot use hash table. thanks --mac -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks"