468,257 Members | 1,420 Online

# nth biggest number in unsorted array

hi friends

guys
i have a question that suppose there is very big array of unsorted number and we have to find nth biggest number in opitmized manner, then how we can do it. n parameter can be also big.

Mine logic is first create descending priority queue in place and then performing removing delete operation nth time

is there is any other optimized method.
May 4 '07 #1
3 2574
svlsr2000
181 Expert 100+
hi friends

guys
i have a question that suppose there is very big array of unsorted number and we have to find nth biggest number in opitmized manner, then how we can do it. n parameter can be also big.

Mine logic is first create descending priority queue in place and then performing removing delete operation nth time

is there is any other optimized method.
If n is smaller, declare an array of n element and store N biggest number in that. But i dont think this might be the best solution.
May 4 '07 #2
If n is smaller, declare an array of n element and store N biggest number in that. But i dont think this might be the best solution.
Is not there any inplace solution withour requiring any other storage array.
May 4 '07 #3
Ganon11
3,652 Expert 2GB
You could always perform an efficient sort on the array and then take the element n places away from the end. That would be an efficiency of O(n log n).
May 4 '07 #4