Indexed Permutations |
You are to write a program that has to generate particular permutations of the first N nonegative integegers. Consider all of the permutations of the integers { 0, 1, 2, ..., N } to be ordered lexicographically, i.e., the order they would appear in a dictionary if 0 == a, 1 == b, 2 == c, and so on. Thus, under this ordering and indexed from zero, the six permutations of the sequence { 0, 1, 2 } are
zeroth: { 0, 1, 2 }
first: { 0, 2, 1 }
second: { 1, 0, 2 }
third: {1, 2, 0 }
fourth: { 2, 0, 1 }
fifth: { 2, 1, 0 }
5 3 0 12 10 10 1000000000 13
2 1 0 0 1 2 3 4 5 6 7 8 9 10 11 12 0 1 2 3 4 5 7 9 6 8 2 1 0 8 10 7 9 12 4 6 11 3 5