@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 <[email protected]> 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
