Devise a Plan: Solution

Devise plan to solve the problem.

We'll cover the following

We have our strategy. Now, we can try to solve the problem.

Solution

We have to repeat the steps discussed in the strategy in the previous lesson.

Let’s say the correct room number is 15, and we do not know it yet. Here is a viable plan to solve this problem:

  • We can start with the middle number in the given range as our initial guess (e.g., 25).
  • This guess is too high. Our new range will be 1–24.
  • We can guess the middle number in the range. Let’s guess 12.
  • This guess is too low. Our new range is 13–24.
  • We can guess the middle number in the new given range. Let’s guess 18.
  • The guess is too high. Our new range is 13–17.
  • The middle number in the new given range is 15. Let’s guess it. It is the correct number.

This solution looks like this:

Get hands-on with 1400+ tech skills courses.