Input
: the original permutation sequence
(1) find
(2)
if
doesn’t exist
then
(3)
exit
, and next permutation sequence doesn’t exist.
(4)
else
(5) find
(6)
swap
(
,
)
(7) reverse the sub-sequence
(8)
Output
:
is the
next permutation sequence.
(9)
end if
Algorithm 1:
next
_
permutation
(
Ord
).