Hoare partition doesn't work?
问题 I have been trying to implement the Hoare partitioning method, but neither I, nor the computer can't seem to understand it as it is written in Cormen and Wikipedia. The algorithm in both sources looks like this: algorithm partition(A, lo, hi) is pivot := A[lo] i := lo - 1 j := hi + 1 loop forever do j := j - 1 while A[j] > pivot do i := i + 1 while A[i] < pivot if i < j then swap A[i] with A[j] else return j For the following array: 9 3 11 55 4 , after partitioning it with the above function,