Problem 2 In the INSERTIONSORT implementation we showed in class we compared the element we were placing with each eleme
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Problem 2 In the INSERTIONSORT implementation we showed in class we compared the element we were placing with each eleme
Problem 2 In the INSERTIONSORT implementation we showed in class we compared the element we were placing with each element in the sorted subarray until we found the correct position. Since the subarray is sorted we can use binary search to find the correct final position. (Reminder: BinARYSEARCH performs O(logn) comparison in the worst case) (a) [5 points] How does this change impact the total number of comparisons performed in the worst case? Explain your answer. (b) [5 points] Will this change actually improve the worst case asymptotic complexity? Explain your answer.
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!