减治法——搜索第k小元素(Decrease and Conquer by a Factor - Finding the kth smallest element)
问题(Problem)
Find the kth smallest element in an unsorted array.
分割(Partitioning)
Partitioning an array around some pivot element p means reorganising the array so that all elements to the left of p are no greater than p, while those to the right are now smaller.
Lomuto Partitioning
function LomutoPartition(A[lo..hi])
p ⟵ A[lo]
s ⟵ lo
for i ⟵ lo+