Finds the kth smallest element in an array using the quickselect algorithm.
On average it runs in linear time and in the worst case it runs in quadratic
time. In practice, due to a random pivot being used, the runtime will almost
certainly be linear.
The array is modified in place during the algorithm.
If k is out of bounds (k < 0 or k >= length), returns undefined.
Finds the kth smallest element in an array using the quickselect algorithm.
On average it runs in linear time and in the worst case it runs in quadratic time. In practice, due to a random pivot being used, the runtime will almost certainly be linear.
The array is modified in place during the algorithm.
If k is out of bounds (k < 0 or k >= length), returns
undefined.