llhuii's Blog

Happy coding

Permutation

Methods of listing all permutations of a list:
1. Recursive algorithm
2. Lexicographic order
3. Johnson-Trotter algorithm
4. B. Heap's algorithm
references:
http://en.wikipedia.org/wiki/Permutation
http://www.cut-the-knot.org/do_you_know/AllPerm.shtml
http://www.cut-the-knot.org/Curriculum/Combinatorics/JohnsonTrotter.shtml

Tarjan's off-line least common ancestors algorithm

problem 21-3 of CLRS.

See wiki.