Question

In: Computer Science

Generate all permutations of {3, 8, 2} by the Johnson-Trotter algorithm. Show the steps.

Generate all permutations of {3, 8, 2} by the Johnson-Trotter algorithm. Show the steps.

Solutions

Expert Solution

Dear Learner,

Here is the solution to your question.

Johnson-Trotter algorithm basically finds all the permutation of n numbers without going through all the shorter permutations. Furthermore, this algorithm generates the permutation just by swapping a pair of adjacent integers.

In this algorithm, we have directed integers which basically means the direction in which that particular integer will move or swap.Any such integer,which is greater than the next integer in it's direction is said to be 'mobile'. Next, we find the largest 'mobile number' of a series.

Later, as we move on, we will switch the direction of all the integers whose value is greater than the current 'mobile integer'

[NOTE: the '<' and '>' on the left of every integer is representing the direction in which that particular integer is going, and not the actual 'less than' or 'greater than']

To begin with, we first arrange the numbers in descending order

< 2 < 3 < 8

Above, the largest mobile number is 8, so we swap it with the next immediate integer i.e,. 3.

Since 8 is the current mobile number and also the largest, we don't need to change any directions

< 2 < 8 < 3

Again, since 8 is the mobile number we swap it with 2

< 8 < 2 < 3

Now,in the above line we can see that the current mobile number is 3 as it is greater than it's immediate integer and since 8(which is no longer mobile) is greater than 3 we will change its direction.

> 8 < 3 < 2

Now, again, 3 will be swapped withe the next number in its direction.

< 3 > 8 < 2

At last, 2 will be swapped with 8 giving us the final permutation

< 3 < 2 < 8

I hope I have answered the question the way you were expecting. If you still have any doubts or want any further explanation, fell free to ask us in the comment section.

Please leave a like if this was helpful.

Thanks,

Happy Studying.


Related Solutions

Show that the probability that all permutations of the sequence 1, 2, . . . ,...
Show that the probability that all permutations of the sequence 1, 2, . . . , n have no number i being still in the ith position is less than 0.37 if n is large enough. Show all your work.
1. What is A-Star (A*) Algorithm in Artificial Intelligence? 2. A* Algorithm Steps 3. Why is...
1. What is A-Star (A*) Algorithm in Artificial Intelligence? 2. A* Algorithm Steps 3. Why is A* Search Algorithm Preferred? 4. A* and Its Basic Concepts 5. What is a Heuristic Function? 6. Admissibility of the Heuristic Function 7. Consistency of the Heuristic Function 8. Find an Implementation in Java, C or Python just choose in which programming language you prefer only select one.
Let U be a Standard Uniform random variable. Show all the steps required to generate: a...
Let U be a Standard Uniform random variable. Show all the steps required to generate: a Binomial random variable with parameters n = 12 and p = 0.6 a discrete random variable with the distribution P(x), where P(0) = 0.4, P(3) = 0.1, P(7) = 0.2, P(14) = 0.3; a continuous random variable with the density f(x) = 4x 3 , 0 < x < 1; a continuous random variable with the density f(x) = (1/18)x 2 , -3 <...
Give a recursive algorithm to compute a list of all permutations of a given set S....
Give a recursive algorithm to compute a list of all permutations of a given set S. (That is, compute a list of all possible orderings of the elements of S. For example, permutations({1, 2, 3}) should return {〈1, 2, 3〉, 〈1, 3, 2〉, 〈2, 1, 3〉, 〈2, 3, 1〉, 〈3, 1, 2〉, 〈3, 2, 1〉}, in some order.) Prove your algorithm correct by induction.
Intelligent Agents 1. What is A-Star (A*) Algorithm in Artificial Intelligence? 2. A* Algorithm Steps 3....
Intelligent Agents 1. What is A-Star (A*) Algorithm in Artificial Intelligence? 2. A* Algorithm Steps 3. Why is A* Search Algorithm Preferred? 4. A* and Its Basic Concepts 5. What is a Heuristic Function? 6. Admissibility of the Heuristic Function 7. Consistency of the Heuristic Function 8. Find an Implementation in Java, C or Python just choose in which programming language you prefer only select one.
Generate all substrings of set {1, 2, 3} using the bit strings method. Show details of...
Generate all substrings of set {1, 2, 3} using the bit strings method. Show details of your work.
Show the step by step multiplication using Booth’s Algorithm 1. -8 * 2
Show the step by step multiplication using Booth’s Algorithm 1. -8 * 2
All necessary steps much show for these problems, please. Use the Euclidean algorithm to find gcd(12345,...
All necessary steps much show for these problems, please. Use the Euclidean algorithm to find gcd(12345, 54321). Write gcd(2420, 70) as a linear combination of 2420 and 70. The work to obtain the gcd is provided. 2420 = 34(70) + 40 70 = 1(40) + 30 40 = 1(30) + 10 30 = 3(10) + 0 Determine if 1177 is prime or not. If it is not, then write 1177 as a product of primes Find gcd(8370, 465) by unique...
PLEASE SHOW HOW TO SOLVE IN EXCEL SHOW STEPS Refer to the Johnson Filtration problem introduced...
PLEASE SHOW HOW TO SOLVE IN EXCEL SHOW STEPS Refer to the Johnson Filtration problem introduced in this section. Suppose that in addition to information on the number of months since the machine was serviced and whether a mechanical or an electrical repair was necessary, the managers obtained a list showing which repairperson performed the service. The revised data follow. Repair Time in Hours Months Since Last Service Type of Repair Repairperson 2.9 2 Electrical Dave Newton 3 6 Mechanical...
For all hypothesis tests, you must show the four steps: 1. Hypotheses 2. Test statistic 3....
For all hypothesis tests, you must show the four steps: 1. Hypotheses 2. Test statistic 3. p-value or p-value approximation 4. Conclusion sentence (Do no just say ”Reject the null hypothesis” or ”Fail to reject the null hypothesis”) If doing the hypothesis test in jamovi, you must include the jamovi output but show the four steps separately as well. Exercises 1. The Department of Natural Resources (DNR) received a complaint from recreational fishermen that a community was releasing sewage into...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT