Assuming that you mean that you have an array of size 1000 that you
can use as temporary storage, use it as a bit array. Based on the size
of the input numbers, the word size is at least 15 bits, so you have
at least 15,000 bits to use. If the word size is such that you have at
least 20,000 bits, then read through the data one item at a time,
setting the corresponding bit in the bit array. After completing the
input, scan the bit array in order and output the numbers. If you have
less than 20,000 bits, then read through the data twice, first marking
the bits for items between 0 and 14,999. After outputting those
numbers, read the input again, setting bit i-15,000 for every number
between 15,000 and 19,999.

Dave

On Dec 21, 11:56 pm, snehal jain <learner....@gmail.com> wrote:
> Given an array having 16000 unique integers, each lying within the
> range 1<20000, how do u sort it. U can load only 1000 numbers at a
> time in memory

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to