Partition algorithm problem

I need help to solve this algorighm.

1. Let p be the position in the array such that a[p] is the median
of a
, a[m], and a[align=right] (where m is about midway
between left and right).
2. If p is not equal to left, swap a[p] and a
3. Set pivot to a
4. Set i = left + 1 and j = right.
5. While i ≤ j, repeat:
5.1. While i ≤ j and a ≤ pivot, increment i.
5.2. While j ≥ i and a[j] ≥ pivot, decrement j.
5.3. If i < j, swap a and a[j].
6. If j * left, set a
to a[j], and a[j] to pivot.
7. Terminate with answer j.

I know how to solve steps 2-7, step number 1 is a bit tricky.But A small part i was able to solve(i think) Can someone get me any clues at all please?
Sign In or Register to comment.