Question: Given the following algorithm (4 points) Algorithm(B) for j2 to length [A] do key A[j] i- j - 1 while i > 0 and
Given the following algorithm (4 points) Algorithm(B) for j2 to length [A] do key A[j] i- j - 1 while i > 0 and A[i] > key do A[i+1] A[i] ii-1 A[i+1] key (a) Describe the function of this algorithm (2 points) (b) Write a recursive version of this algorithm in pseudocode. (2 points) Given the following algorithm (4 points) Algorithm(B) for j2 to length [A] do key A[j] i- j - 1 while i > 0 and A[i] > key do A[i+1] A[i] ii-1 A[i+1] key (a) Describe the function of this algorithm (2 points) (b) Write a recursive version of this algorithm in pseudocode. (2 points)
Step by Step Solution
There are 3 Steps involved in it
a Function of the Algorithm The given algorithm appears to be an insertion sort algorithm It is ... View full answer
Get step-by-step solutions from verified subject matter experts
