Question: Given input n, Jim has an unsorted array A of nn items and he needs to perform O(logn) search operations on A. He has two
Given input n, Jim has an unsorted array A of nn items and he needs to perform O(logn) search operations on A. He has two algorithms in mind to achieve this:
Algorithm one: Sort A using merge sort and then perform all of O(logn) search operations using binary search.
Algorithm two: Perform all of O(logn) search operations directly on A using linear search.
Present the running times of each of the two algorithms separately and select the algorithm you would suggest to Jim by determining which one is asymptotically faster.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
