Re: [algogeeks] kth largest element in an unsorted list

2012-01-14 Thread saurabh singh
nth order statistics Saurabh Singh B.Tech (Computer Science) MNNIT blog:geekinessthecoolway.blogspot.com On Sat, Jan 14, 2012 at 8:23 PM, Piyush Grover wrote: > you can do it in nlogk or n+klogn time. > > create a min-heap tree of size k with f

Re: [algogeeks] kth largest element in an unsorted list

2012-01-14 Thread Piyush Grover
you can do it in nlogk or n+klogn time. create a min-heap tree of size k with first k nodes. Add k+1..n nodes in the tree. Everytime you insert a node in the tree check if it's greater than the root node. If yes remove root node and insert the new node (logk operations). So time complexity will be

[algogeeks] kth largest element in an unsorted list

2012-01-14 Thread Ashish Goel
Hi, how can we do so in O(n) forming a heap or a tree with each node keeping children in its left node still is nlogn Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 -- You received this message because you are subscribed to the Google Groups "Al