Question: Permutation Generator Take a look at the algorithm Permutation Generator given in the text Mathematical Structures for Computer Science on pages 282-283. The algorithm takes


Permutation Generator
Take a look at the algorithm Permutation Generator given in the text Mathematical Structures for Computer Science on pages 282-283. The algorithm takes a set of n integers and generates a list of all possible permutations of those integers. Answer the following questions to analyze the algorithm.
1. If the set consists of the integers {1,2,3,4,5}, how many permutations are possible?
2. If the set consists of the integers {1,2,3,4,,10}, how many permutations are possible?
3. Fill in the table below showing the number of permutations possible on a set of n integers for various values of n. Use scientific notation where appropriate.
| n | Number of Permutations |
| 5 |
|
| 10 |
|
| 15 |
|
| 20 |
|
| 25 |
|
| 30 |
|
4. If the set consists of the integers {1,2,3,4,n}, how many permutations are possible?
5. Classify the algorithm using Big-O notation.
6. If it takes a computer 10-9 seconds to generate one permutation, how long would it take to run the algorithm on the set {1,2,3,4,10} ?
For which values of n is it reasonable to run this algorithm on the set {1,2,3,4,n} ? Explain.
Please answer all
ALGORITHM PERMUTATION GENERATOR PermGenerator(integer n 22) 1/generates in lexicographical order all permutations //of the integers in the set {1,..., n} Local variables: //indices of permutation elements integers i, j integer k //for loop counter integers d,, d,, ..., d., //left to right elements of a permutation ALGORITHM PERMUTATION GENERATOR PermGenerator(integer n 22) 1/generates in lexicographical order all permutations //of the integers in the set {1,..., n} Local variables: //indices of permutation elements integers i, j integer k //for loop counter integers d,, d,, ..., d., //left to right elements of a permutation
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
