Question: 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
public class TernarySearch public static int ternarySearchint arr int k... View full answer
Get step-by-step solutions from verified subject matter experts
