Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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. 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Starting Out With Programming Logic And Design

Authors: Tony Gaddis

5th Edition

0134801156, 9780134801155

More Books

Students also viewed these Algorithms questions

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago