|
|
|
|
|
by lorenzhs
3392 days ago
|
|
But std::distance(first, last) is how n is defined. std::nth_element is typically implemented using a fancy version of quickselect called introselect. You can imagine quickselect as a version of quicksort where the recursive call is only executed on the side which contains the element. Introselect adds some fanciness to ensure worst-case linear running time if quickselect takes too long (bad pivot selection). |
|