Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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 binary searcl (a) (10 points) Consider the modified binary search algorithm (called ternary search) so that it splits the sorted arrav 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 (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/v)-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 can be done when vn is not an integer but will be more complicated)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started