[prev] 25 [next]

Non-randomised Quicksort (cont)

3  6  5  2  4  1    // swap a[left=1] and a[right=5]

3  1  5  2  4  6    // swap a[left=2] and a[right=3]

3  1  2  5  4  6    // swap pivot and a[right=2]

2  1   | 3 |   5  4  6

1  2   | 3 |   5  4  6

1  2   | 3 |   4   | 5 |   6