468,257 Members | 1,420 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,257 developers. It's quick & easy.

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

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

reply views Thread by Thomas Wegener | last post: by
3 posts views Thread by David Scemama | last post: by
30 posts views Thread by vim | last post: by
29 posts views Thread by fdmfdmfdm | last post: by
reply views Thread by kermitthefrogpy | last post: by
reply views Thread by zattat | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.