Hi,

I think this question is very common now a days..

Answer is use bit vector.

Here we are told that 1 million integers. so just create a bit array
of 1m.

make bit true if it is available.

start from 1m until you get 10 values with true.

If interviewer says that it could have duplicate numbers... heap
sounds good solution to go...

-VIpul



On Dec 24, 11:20 am, Satya <satya...@gmail.com> wrote:
> @Dave, you are right. MAX Heap is correct for your always 11th position
> removal logic.
> .........
> Satya
>
>
>
>
>
>
>
> On Fri, Dec 24, 2010 at 9:45 PM, Satya <satya...@gmail.com> wrote:
> > @Dave, I think you meant* *MIN** Heap here?
>
> > On Fri, Dec 24, 2010 at 6:46 PM, Dave <dave_and_da...@juno.com> wrote:
>
> >> @Bittu: Using the first 10 numbers, build a max heap. Then add each
> >> number into the 11th array position (always the 11th position) and
> >> perform the up-heap operation. At the end of the input, discard the
> >> 11th number in the heap. The remaining numbers will be the 10 maximum.
> >> O(n log k) where n = the number of items in the list and k = the
> >> number of maximum items you want.
>
> >> Dave
>
> >> On Dec 24, 3:32 am, bittu <shashank7andr...@gmail.com> wrote:
> >> > You Have File of Containing 1 Million Integers You need To Find 10
> >> > Maximum Integer Out of Them.How You Will Do That ...what is Time &
> >> > space Complexcity of Algorithm that you will use....then optrmize the
> >> > solution..
>
> >> > Constraints- U can't Store Whole File in memory @ one time e.g. if u
> >> > will do that gigabyt eof memory may be reuqired so that should be
> >> > avoided.
>
> >> > Regards
> >> > Shashank Mani Narayan
> >> > Birla Instute of Technology,Mesra
>
> >> --
> >> 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<algogeeks%2bunsubscr...@googlegroups
> >>  .com>
> >> .
> >> For more options, visit this group at
> >>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 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