Problem

Generate all permutations of {1, 2, 3, 4} by a. the bottom-up minimal-change algorithm...

Generate all permutations of {1, 2, 3, 4} by

a. the bottom-up minimal-change algorithm.

b. the Johnson-Trotter algorithm.

c. the lexicographic-order algorithm.

Step-by-Step Solution

Solution 1

The objective is to generate all permutation for the provided set {1, 2, 3, 4}.

a.

Bottom-up minimal change algorithm:

• The solution can be arrived by inserting n in each of the possible positions among elements of every permutation of n-1 elements.

• All the permutations obtained in this fashion will be distinct and their total number will be n(n-1)! = n!

• It is provided that 4! and permutations for a set of integers are {1, 2, 3, 4}.

• In the Bottom-up minimal change algorithm, each permutation is obtained from its immediate predecessor by exchanging just two elements in it.

• That is, as by inserting an element in each of the possible positions among elements of every permutations of (n –1) element. (Either left to right or right to left)

Here are the permutations for the set {1, 2, 3, 4} by using the Bottom-up minimal change algorithm as shown below:

Picture 1

b.

Johnson-Trotter algorithm:

Johnson-Trotter algorithm generates n! without explicitly generating permutations for smaller values of n.

Algorithm process:

In this process, a direction is associative with each component k in a permutation and direction is represented by an arrow above the component.

The component k is said to be mobile, if the arrow points to a smaller value adjacent to it.

Given set is {1, 2, 3, 4}: size of the set as n = 4 and largest mobile component is shown in bold.

Largest element in the set k = 4, and swap k with adjacent component.

Reverse the direction component k and largest element in the remaining set k = 3, and swap k with adjacent component.

Largest element in the set k = 4, and swap k with adjacent component.

Reverse the direction component k and largest element in the remaining set k = 3, and swap k with adjacent component.

Largest element in the set k = 4, and swap k with adjacent component.

Reverse the direction component k and largest element in the remaining set k = 3, and swap k with adjacent component.

Largest element in the set k = 4, and swap k with adjacent component.

Reverse the direction component k and largest element in the remaining set k = 3, and swap k with adjacent component.

Largest element in the set k = 4, and swap k with adjacent component.

Reverse the direction component k and largest element in the remaining set k = 3, and swap k with adjacent component.

Largest element in the set k = 4, and swap k with adjacent component.

Therefore, the final list would be listed as a dictionary if the numbers were interpreted as letters of an alphabet, for n = 4,

Picture 37

c.

Lexicographic-order algorithm:

• In lexicographic ordering, a permutation A = a1a2 a3……an is less than (or precedes) a permutation B = b1 b2b3…….bn, if

• For example, take two sets, the first two positions and. But they differ in the third position. Since, the then permutation 2134 precedes the permutation 2143 in lexicographic ordering.

• For instance, least significant item in the list at the head and the next greater element than (1 2 3 4) is (2 1 3 4). Since, the most significant tail of the list doesn’t change, and the next greater permutation differs in the least significant elements.

• In the given set, there are 4! = 24 permutations of the set {1, 2, 3, 4}. To make a greater permutation, some element of the list must be replaced by a larger element to its left; to make the next permutation, the replacement must happen as far to the left as possible, in the least significant position, and the replacing element must be as small as possible.

The permutations of the list (1 2 3 4) in lexicographic order are as follows:

Picture 13

Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4.3
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT