Find the kth smallest element of an array
This problem is different from the ones we examined: You cannot predict in advance the size of either the smaller problems or the base case in the recursive solution to the kth smallest-element problem.
1. Decide a pivot element in the array P with index Pindex.
2. Partition the array into three parts: elements < P(call it S1), P , and elements >P (call it S2).