The wikipedia introselect says the worst time complexity is O(n)
.
However, refer to this answer, https://stackoverflow.com/a/29146718/7721525, some implementation of introselect runs 2lg(n)
times of partition_pivot
, which has a worst time complexity of O(nlg(n))
. Whether you use medians_of_medians algorithm of heapsort, the time complexity is already O(nlg(n))
.
How to achieve a worst time O(n)
introselect?
If we use a constant k
instead of 2lg(n)
. Can we say the time is O(n)
? Can you give me some practical choices of k( must be a constant)?