Any algorithm must in worst case lead to O(n) if the elements are not
unique. Take the case:
1 2 3 4 5 6
as all the elements satisfy the condition of of key==index . we must go
someway to each element.
Hence O(n).

This may be somehow made less if the element are given to be unique by using
heap.

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to