Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question 5 (20%) Here is the pseudo code for INSERTION-SORT INSERTION-SORT(A) 1 for j = 2 to A. length 2 keyAU] 3 Insert AU] into

image text in transcribed
Question 5 (20%) Here is the pseudo code for INSERTION-SORT INSERTION-SORT(A) 1 for j = 2 to A. length 2 keyAU] 3 Insert AU] into the sorted sequence A[1 ..j -1]. 4 5 while i >0 and Ali] > key 7 i=i-1 8 Ali +11key (a) Observe that the while loop of line 5-7 of the INSERTION-SORT uses linear search to scan through the sorted subarray Al1..j -1]. Can we use a binary search instead to improve the overall worst case running time of insertion sort to ?(n In n)? You must justify your answer. (10 points) (b) INSERTION-SORT can be expressed as a recursive procedure as follows. In order to sort A[1 ..n], we recursively sort A[1..n-1 and then insert A[n] in to the sorted array A[1..n-1]. Write a recurrence for the running time of this recursive version of insertion sort. (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

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

More Books

Students also viewed these Databases questions

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago