o
iterate
r
from right to left until we find an element less than the pivot.
o
if both elements are found, swap them.

85
(
l
), 24, 63, 45, 17, 31,
94
(
r
),
50
(
x
). [85>50, no more right iterations for
l
. 91 not less than 50, continue right to
left iteration for
r
.]
85
(
l
), 24, 63, 45, 17,
31
(
r
), 94,
50
(
x
). [since 85>50 and 31<50, we swap the elements.]
31
(
l
), 24, 63, 45, 17, 85,
94
(
r
),
50
(
x
). [31 not greater than 50, 94 not less than 50. continue iterations.]
31,
24
(
l
), 63, 45, 17,
85
(
r
), 94,
50
(
x
). [24 not greater than 50, 85 not less than 50. continue iterations.]
31, 24,
63
(
l
), 45,
17
(
r
), 85, 94,
50
(
x
). [65>50 and 17<50, swap them.]
31
(
l
), 24, 17, 45, 63, 85,
94
(
r
),
50
(
x
). [Similar iterations continue until
l
and
r
both equal 63. Then 63 and 50 swap
to produce the following sequence].
(L){31, 24, 17, 45},