Re: [algogeeks] Re: A Billion Number Question

2011-03-26 Thread Wladimir Tavares
I think I find the max and then print max + 1 is not a correct strategy because overflow can occur or find the min and print min-1 underflow can occur. If you use a bitset, you can store all the values ​​that appear in 10Mb. I believe that these integers are in the file are integers that are

[algogeeks] Re: A Billion Number Question

2011-03-18 Thread Dave
Assuming the data is 32-bit unsigned integers: Treat your memory (either amount) as an array A[] of M integers. E.g., with 10 MB of memory, M = 2,500,000. Initialize the array to zero. Read through the file. For each integer x, increment A[x mod M]. There will be at least one bin whose count is

[algogeeks] Re: A Billion Number Question

2011-03-17 Thread arpit.gupta
read the first no. . now ans= first no +1; if now ans is encountered while reading the next nos. add 1 to ans. i.e. ans++; On Mar 17, 2:18 am, bittu shashank7andr...@gmail.com wrote: Given an input file with four billion integers, provide an algorithm to generate an integer which is not

[algogeeks] Re: A Billion Number Question

2011-03-17 Thread Don
This only works if the file is sorted. If the file starts out with values 5,7,6,... and never contains another 7, the result will be 7, which is in the file. On Mar 17, 12:19 pm, arpit.gupta arpitg1...@gmail.com wrote: read the first no. . now ans= first no +1; if now ans is encountered while