Question: In the INSERTION-SORT algorithm in Sec. 2.1 line 5-7 uses a linear search through the sorted subarray A[1..j =1] to find the proper position for

In the INSERTION-SORT algorithm in Sec. 2.1 line 5-7 uses a linear search through the sorted subarray A[1..j =1] to find the proper position for A[J]. The following is a variant of Insertion Sort where linear search is modified into (iterative) binary search (given A [1..j-1] is a sorted sub-sequence). Can the overall running time of this version of the insertion sort be improved to Theta(nlgn)? Answer the questions below- B Insertion Sort (A, n) for j leftarrow 2 to a key leftarrow = A[j]//insert A[j] into the sorted sequence A[1.. j-1] left leftarrow 1 right leftarrow- j-1 while
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
