subject

A permutation is a reordering of elements in a list. For example, 1, 3, 2 and 3, 2, 1 are two permutations of the elements in the list 1, 2, 3. In this problem, we will find all the permutations of the elements in a given list of numbers using recursion. Consider then the three-element list 1, 2, 3. To see how recursion comes into play, consider all the permutations of these elements: We observe that these permutations are constructed by taking each element in {1,2,3} {1,3,2} {2,1,3} {2,3, 1} {3, 1,2} {3, 2, 1} the list, putting it first in the array, and then permuting all the remaining elements in the list. For instance, if we take 1, we see that the permutations of 2, 3 are 2, 3 and 3, 2. Thus, we get the first two permutations on the previous list. For a list of size N, we pull out the k-th element and append it to the beginning of all the permutations of the resulting list of size N-1. We can work recursively from our size N case down to the base case of the permutations of a list of length 1 (which is simply the list of length 1 itself). *Caution* You are not allowed to use Matlab built-in functions such as: perms(), pemute(), nchoosek(), or any other similar functions. Task Complete the function genPerm using the function declaration line: 1 function (allPerm] genPerm(list) ⢠list - a 1D array of unique items (i. e. [1,2,3])
⢠allPerm - a cell array of N! 1D arrays. Each of the 1D arrays should be a unique permutation of items of list. Use a recursive algorithm to construct these permutations. For a list of size N there will be N! permutations, so do not test your code for arrays with more than a few elements (say, no more than 5 or so). Note that writing this function requires good knowledge of cell arrays, so it is recommended that you review that material before undertaking the programming task.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 07:00
You need a quick answer from a coworker. the most effective way to reach your coworker is through a. cloud server b. instant message c. teleconference d. telepresence
Answers: 1
question
Computers and Technology, 23.06.2019 19:30
Of the following pieces of information in a document, for which would you most likely insert a mail merge field?
Answers: 3
question
Computers and Technology, 24.06.2019 01:00
Mastercard managers are motivated to increase (1) the number of individuals who have and use a mastercard credit card, (2) the number of banks and other clents who issue mastercards to customers and/or employees, and (3) the number of locations that accept mastercard payments. discuss how mastercard could use its data warehouse to it expand each of these customer bases.
Answers: 3
question
Computers and Technology, 24.06.2019 02:30
How to apply the fly in effect to objects on a slide
Answers: 1
You know the right answer?
A permutation is a reordering of elements in a list. For example, 1, 3, 2 and 3, 2, 1 are two permut...
Questions
question
English, 01.12.2021 03:20
Questions on the website: 13722363