Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started