Skip to content

Latest commit

 

History

History
27 lines (19 loc) · 651 Bytes

README.md

File metadata and controls

27 lines (19 loc) · 651 Bytes

Johnson Trotter Algorithm

This program computes all permutations of a lexicographically sorted string using the Johnson and Trotter algorithm.

It is assumed that the string input is already sorted lexiographically.

Inputs: String, "n" number of permutations that the user wishes to compute of the given string. Output: n number of permutations

ex.

Input: "abcdef", 10

Output:

abcdef
abcdfe
abcfde
abfcde
afbcde
fabcde
fabced
afbced
abfced
abcfed

Compile using "g++ johnsonTrotterMain.cpp" or "g++ -std=c++14 johnsonTrotterMain.cpp"