Question: PLEASE help me understand this :( 5. Consider the following sorting algorithm (which you may assume is correct), called initially with i -1 and j
PLEASE help me understand this :(

5. Consider the following sorting algorithm (which you may assume is correct), called initially with i -1 and j - n to sort a list of n numbers in array A: Sort(A, i,j) 1 if Ali]> AUl then exchange Ai]ALj ifi+1 j 2 4 then return Sort(A, .j-k) 7Sort(A, i +k.j) Sort(A, .j-k) Suppose SORT takes as input list (5, 4, 3, 2, 1). During its execution, how many times is an element compared to another element in A? ANSWER ONLY 4 How many of these comparisons result in swaps? (Compare this with the worst- case of Merge-Sort for five numbers.) ANSWER ONLY 4 What is the worst-case time for SORT, in asymptotic notation? ANSWER ONLY theta(nlog3/23)(5 points]) (5 points) (10 points) 5. Consider the following sorting algorithm (which you may assume is correct), called initially with i -1 and j - n to sort a list of n numbers in array A: Sort(A, i,j) 1 if Ali]> AUl then exchange Ai]ALj ifi+1 j 2 4 then return Sort(A, .j-k) 7Sort(A, i +k.j) Sort(A, .j-k) Suppose SORT takes as input list (5, 4, 3, 2, 1). During its execution, how many times is an element compared to another element in A? ANSWER ONLY 4 How many of these comparisons result in swaps? (Compare this with the worst- case of Merge-Sort for five numbers.) ANSWER ONLY 4 What is the worst-case time for SORT, in asymptotic notation? ANSWER ONLY theta(nlog3/23)(5 points]) (5 points) (10 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
