Question: A) Using the Binary Search algorithm. Write the algorithm in pseudocode. Analyze the algorithm for time needed as the size n of the problem changes.
A) Using the Binary Search algorithm. Write the algorithm in pseudocode. Analyze the algorithm for time needed as the size n of the problem changes.
B) Suppose we write an algorithm called Ternary Search where instead of dividing the sorted array into two parts, we search by dividing the relevant part of the array into three parts, determine which part the item we are looking for appears, and recursively search for the item in this part. Write this algorithm in pseudocode. Analyze the algorithm for time needed as a function of the size n of the problem.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
