Question: 7. A binary search algorithm splits a sorted input array into two subsets of almost equal size and recursively searches in one of these two

 7. A binary search algorithm splits a sorted input array into

7. A binary search algorithm splits a sorted input array into two subsets of almost equal size and recursively searches in one of these two subsets after making one comparison. Consider the following three modifications of binarv search algorithm (a) (10 points) Consider the modified binary search algorithm (called ternary search) so that it splits the sorted array not into two subsets of almost-equal sizes, but into three subsets of sizes approximately one-third. If this ternary search algorithm need to recursively search in one of these three subsets of approximately one-third size, how many comparisons need to be made in each step? Write down the recurrence for this ternary search algorithm and find the asymptotic runtime of this algorithm (b) (10 points) Consider another variation of the binary search algorithm so that it splits a sorted array into two sets of sizes approximately one-third and two-thirds. Write down the recurrence for this search algorithm (for best and worst case) and find the asymptotic runtime of this algorithm for best case and worst case. (c) (10 points) Consider yet another variation of the binary search algorithm so that it splits a sorted array into Vn sets of sizes (n/Vn) - Vn each. Write down the recurrence for this search algorithm and find the asymptotic runtime of this algorithm. For simplicity assume vn is integer, which is of course not the case for all n but it will simplify your analysis. (The same analysis carn be done when Vn is not an integer but will be more complicated)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!