Answered step by step
Verified Expert Solution
Link Copied!

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 :(

image text in transcribed

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What aspects would it be impossible to capture?

Answered: 1 week ago

Question

Enhance your words with effective presentation aids

Answered: 1 week ago