Hey guys,

I'm having trouble understanding what the "Systematic generation of all permutations" algorithm in wikipedia (here:

Permutation - Wikipedia, the free encyclopedia) specifically does. The four steps are below.

- Find the largest index
*k* such that *a*[*k*] < *a*[*k* + 1]. If no such index exists, the permutation is the last permutation. - Find the largest index
*l* such that *a*[*k*] < *a*[*l*]. Since *k* + 1 is such an index, *l* is well defined and satisfies *k* < *l*. - Swap
*a*[*k*] with *a*[*l*]. - Reverse the sequence from
*a*[*k* + 1] up to and including the final element *a*[*n*].

If anyone could just clarify this a little, would be great.

Thanks