Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a Java program that searches a sorted list of n items by dividing it into three sublists of almost n/3 items. The algorithm
Write a Java program that searches a sorted list of n items by dividing it into three sublists of almost n/3 items. The algorithm finds the sublist that might contain the given item and divides it into three smaller sublists of almost equal size. The algorithm repeats this process until it finds the item or concludes that the item is not in the list. The Java program and the corresponding function(s) should be flexible enough to deal with different cases and example data should be provided in the main function of this Java program to check its correctness. You must use the divide and conquer strategy to solve this problem. Hints (for example): The algorithm that will find the location of the search key (e.g., key) in 'Array' must return 0 if the key is not in the Array. If the key is in the Array, the function will return its location. [15 pts] Q1.b. Analyze location-finding algorithm and give its complexity based on Theta notation [5 pts]. Answer: (Please write your answer here, add required space if needed)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
public class TernarySearch public static int ternarySearchint arr int k...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