Question: 1. Your program generates a random integer number between 1 and 1,000. Then it uses the famous binary search algorithm to automatically guess the

1. Your program generates a random integer number between 1 and 1,000. 

1. Your program generates a random integer number between 1 and 1,000. Then it uses the famous binary search algorithm to automatically guess the generated random number. For each try, count the number of guesses to guess the random number correctly. Feel free to use any binary search algorithm implementation out there as it is. 2. Repeat the previous step 10,000 times. Then compute the average number of guesses out of 10,000 tries. 3. Repeat the previous two steps with random numbers between 1 and 1,000,000 instead of 1,000 (max number) Expected Output: 1. The random numbers between 1.. 1K: Total guesses:89968 Avg:8.9968 2. The random numbers between 1.. 1M: Total guesses: 1895077 Avg:18.95077

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Algorithms Questions!