Question: As you know from Discrete Math, a permutation is any possible ordering of the distinct items of a set S . If | S |
As you know from Discrete Math, a permutation is any possible ordering of the distinct items of a set S If S n there are n permutations. This means that for large sets, it is computationally infeasible to generate all possible permutations. One wellknown algorithm for generating set permutations at least for small sets is presented below:ALGORITHM JohnsonTrottern Input: a positive integer n Output: A list of all permutations of ninitialize the first permutation as n with directions pointing leftwhile the last permutation has a mobile elementfind its largest mobile element kswap k and the element to which k is directedreverse the direction of all elements that are larger than kadd the new permutation to the listNote: an element is mobile if its direction points to a smaller adjacent element
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
