Skip to content

ppande574/Johnson_Trotter_Algorithm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

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"

About

This program computes all permutations of a lexiographically sorted string.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages