Question: Consider the following sorting algorithm (the UNH sort) to sort an array A[1..n]. for i = n-1 downto 1 do for j = 1 to
Consider the following sorting algorithm (the UNH sort) to sort an array A[1..n]. for i = n-1 downto 1 do for j = 1 to i do if A[j] > A[j+1] then swap(A[j],A[j+1])
(a) Trace this sorting algorithm on the list 8, 5, 4, 7, 9, 3. i.e. show what the list looks like after each iteration of the outer loop. Also, calculate the exact number of total data comparisons made.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
