Question: How many times does a binary search need to execute to find its value? Recall from our lesson that the number of iterations is roughly
How many times does a binary search need to execute to find its value? Recall from our lesson that the number of iterations is roughly a log base relationship.
In this exercise, you are going to calculate the maximum iterations and the actual iterations needed to find a random value in arrays of size k and k
You are given helper methods to calculate the maximum iterations, generate the random array, and do the binary search. You are also given a counter variable that increments each time your recursive binary method is called.
You will need to come up with the remainder of the code.
Sample Output
Array Size:
Max iterations:
Actual iterations:
Array Size:
Max iterations:
Actual iterations:
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
