Answered step by step
Verified Expert Solution
Question
1 Approved Answer
4. Recursive Algorithm and Analysis (6 points) Suppose company X has hired you as a software engineer. Company X is desperate to improve the run
4. Recursive Algorithm and Analysis (6 points) Suppose company X has hired you as a software engineer. Company X is desperate to improve the run time of their software. Rather than allow you to use the standard binary search algorithm, company X demands you create a new version. Since recursively dividing the array into two parts is so efficient for searching, the bigwigs at company X conclude dividing the array into three parts will be even more efficient. This new "3-ary" search divides the given sorted array into 3 equal sized sorted subarrays. It finds which subarray will contain the given value and then recursively searches that subarray. If the given value is in the array you should return true. Otherwise you should return false. (1) (2 points) Write up this new recursive algorithm using pseudocode. (Hint: For simplicity you can assume the number of elements in the given sorted array, n, is a power of 3) (2) (1 point) Create a recurrence to represent the worst case run time of our new "3-ary" search from the pseudocode. (Hint: The worst case run time occurs when the given value is not in the array) (3) (2 points) Use master theorem to solve your above recurrence relation. (4) (1 point) Compare this asymptotic run time to that of binary search. Does our new algorithm perform significantly better than binary search? (5) (0 points - Just for fun) Try comparing the constants of binary search and "3-ary" search. You can use the change of base formula for log to convert both to log, n
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