Re: [algogeeks] Sorting for large data

2012-01-14 Thread Deepak Nettem
External Memory Sort. The Algorithm is based on Merge Sort. Divide data into chunks of the size of your RAM. Let's say you have k chunks. Such that k x size of RAM = size of your total data. Sort the chunks independently. Perform a k-way merge of these chunks. On Sat, Jan 14, 2012 Could any

Re: [algogeeks] Detect a loop with just head ptr given

2011-12-08 Thread Deepak Nettem
If you allow storing an extra bit with every node (to mark whether a node has been visited), you can do it with just one pointer. But that's less space efficient (O(n)) than using two pointers of varying speeds. On Thu, Dec 8, 2011 at 9:04 AM, Ankur Garg ankurga...@gmail.com wrote: U cant

Re: [algogeeks] facebook interview question

2011-12-04 Thread Deepak Nettem
Greetings! The strategy should be to process the elements in pairs - and compare the larger element with current maximum, and smaller element with current minimum. loop runs upto n in steps of 2, and in each iteration, there are 3 comparisons: - between (i)th and (i+1)th element - between min(i,