# Permutation Recursion for C++

The objective is to write a recursive program to generate and print all the derangements of a set S = {0, . . . , n-1} with n elements. First, let us define a derangement. A permutation of a set S is a bijection ^ from S to itself. A derangement is a permutation where ^(i)!= i for all i element of S. One way to represent a permutation ^ : {0, . . . ,n-1} > {0, . . . , n-1} is by storing its values in an array P of size n, where P[i] contains ^ (i). Expressed in terms of an array, a derangement is an array P of size n containing each value in {0, . . . , n-1} exactly once, and where for each i, P[i]!=i is true. Generate and print all the derangements of the set S = {0, . . . , n-1} for n = 2 to 4. Print also the number of derangements generated for each n. Hint: Consider writing a recursive function where each invocation is responsible for generating the entry p[i] for a single index i. In my own words: If you have difficulty understanding the above question. Basically it's a recursive derangment generator with n=2 and n=3 and n=4 the output of the program should look n=2 //01 //not displayed since 0 is in 0 place 10 n=3 //012 //not displayed since 0 is in 0 place //021 //not displayed since 0 is in 0 place //102 //not displayed since 2 is in 2 place 120 201 //210 //not displayed since 1 is in 1 place and the derangements of 0123 ... ...

## Deliverables

1) Complete and fully-functional working program(s) in executable form as well as complete source code of all work done.

## Platform

I have been given the following hint to start, program should be based on this recursion: void perm(int A[], int n, int k) { // base case if (k>=n) return; for (int i=0; i //recursion { if (notused(A,n,k,i)) A[k]=i; perm(A[],n,k+1); }

Tentang Majikan:

ID Projek: #3212800

newmanvw

See private message.

\$3 USD dalam sehari
(3 Ulasan)
0.5

## 10 pekerja bebas membida secara purata \$34 untuk pekerjaan ini

HaroldHardy

See private message.

\$21.25 USD dalam sehari
(86 Ulasan)
5.8
unamigo

See private message.

\$11.05 USD dalam sehari
(51 Ulasan)
5.3
bogdan123vw

See private message.

\$12.75 USD dalam sehari
(48 Ulasan)
3.8
thextvw

See private message.

\$8.5 USD dalam sehari
(42 Ulasan)
3.4
codexpertfl

See private message.

\$42.5 USD dalam sehari
(5 Ulasan)
3.5
sbuvw

See private message.

\$34 USD dalam sehari
(1 Ulasan)
1.9
kirikavw

See private message.

\$8.5 USD dalam sehari
(0 Ulasan)
0.0
antarez

See private message.

\$170 USD dalam sehari
(0 Ulasan)
0.0
karanchecker

See private message.

\$25.5 USD dalam sehari
(0 Ulasan)
0.0