Guess the Number: Binary Search

guess-the-number-quizBefore attempting this challenge, make sure you have completed our previous Guess the Number challenge first where the player plays against the computer.

In this version, the player will be asked to enter a number between 1 and 100. The computer will then use a binary search algorithm to try to guess the correct number keeping the number of guesses to a minimum.

The binary search is a very effective algorithm to search through a large list that is already sorted, in our case the list of numbers from 1 to 100. It is based on the following flowchart:
binary-search-algorithm

Complete the Code



unlock-access

Solution...

The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 3.1 / 5. Vote count: 25

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: