Question: Question 1 ( 4 points ) Consider the following backtracking algorithm for generating all permutation of an array of numbers: Permute , a ) if

Question 1(4 points)
Consider the following backtracking algorithm for generating all permutation of an array of numbers:
Permute , a)
if n=i
print a
else
for )=1;1(n;1++
swap a[1] and a[n]
Permute (n-1, a)
swap a[i] and a[n]
Now suppose the function is invoked as follows:
a[1]=7
a[2]=8
a[3]=9
Permute , a)
Specify the order beside each number below matching the order in which they will be printed by the above algorithm.
879
798
897
 Question 1(4 points) Consider the following backtracking algorithm for generating all

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!