In the graphic representation of Hoare's parititon:
http://i.imgur.com/OtMaNsn.png
Why does 'j' decrement by 1 when 'i' reaches 6? Since A[j] <= pivot and A[i] >= pivot at that point, shouldn't A[i] swap with A[j]? I am a bit confused about this part.
The pseudo code I am following is this:
//Partition array from A[p] to A[r] with pivot A[p]
//Result: A[i] ≤ A[j] for p ≤ i ≤ q and q + 1 ≤ j ≤ r
x = A[p]
i = p - 1
j = r + 1
while true // infinite loop, repeat forever
repeat j = j - 1
until A[j] <= x
repeat i = i +1
until A[i] >= x
if i < j
swap A[i] <-> A[j]
else return j