Assume that we run the following algorithm on an array A with n integer elements: for i=1 to n-1 for j=0 to n-i-1 if A[j
Posted: Mon Jul 11, 2022 12:50 pm
Assume that we run the following algorithm on an array A with n integer elements: for i=1 to n-1 for j=0 to n-i-1 if A[j] > A[i+1] swap A[j] and A[i+1] a) If the input is: A[0] = n; A[1] = n − 1; · many swaps will be made. --- ; A[n 1] = 1, then how b) How many comparisons will be made in general?