The function will know it hit the base case because the


(program in c)

void perm_rec_1(int N, int nr_values) - A recursive SOLUTION. The wrapper function that will be called from main() must have the signature shown here "void perm_rec_1(int N, int nr_values)" and it does NOT have to be recursive.

However this wrapper function can call a helper function and the helper function can have any number of arguments (of any type) and it MUST be recursive.

The recursive solution should work as follows:

The function will know it hit the base case because the position (or the column) is out of bounds (NOT because you generated all possible permutations).

(For example, for 3 positions and 2 values, the total number of permutations is 8 (=2^3). Do not count the different permutations and stop when you reached 8. Instead, stop because now you are trying to set position 4 and that is out of bounds.)

In the base case print the array

In the recursive case do something similar to what happens in the queens program. There, in the recursive case, there is a loop to try and place the queen at all the columns on this row and if it finds a good position, it places it there and makes a recursive call to put a queen on the next row.

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: The function will know it hit the base case because the
Reference No:- TGS02899784

Expected delivery within 24 Hours