What's the fastest way to find the Kth smallest value in an unsorted list without sorting?

cs.stackexchange https://cs.stackexchange.com/questions/70194

  •  04-11-2019
  •  | 
  •  

Question

My initial algorithm:

  1. Compare element 0 with every other element, keeping track of how many elements are less than it.
  2. Repeat for each element until an element that is greater than exactly (k-1) elements is found.

I assume this would take $O(n^2)$ in the worst case. Can a faster runtime be achieved without sorting the list?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange
scroll top