Imagine playing a number guessing game. A side is a number from 0 to N he's holding it, and the other side is trying to find that number by taking turns guessing. Number-holding side estimate he has to offer one of the following three options in response to the party that did it: 1-Your guess is correct, you found the number I kept (Game Over). 2-Your estimate is wrong, but you are closer to the correct estimate than the previous estimate. 3-the wrong estimate and the correct estimate are further away than the previous estimate. To find the estimated number in an environment where all the information is these, a strategy will be followed: Make a prediction (N/2) from the exact middle of N with 1   Begin: Find out the answer to your guess. [answer=answer_ogren (guess)] If the answer is equal to 1, the game is over, you can leave. If the answer is equal to 2, you are going in the right direction, keep the forecast direction; If you're heading for small numbers, the new N is now N/2. Make a guess from the middle of 1 to N / 2 and go back to the beginning. If you're heading for big numbers, the new 1 is now N/2. Make a guess right in the middle of N / 2 and go back to the beginning. If the answer is equal to 3, you are going in the wrong direction, change the direction of the guess; If you're heading for small numbers, the new 1 is now N/2. Make a guess right in the middle of N / 2 and go back to the beginning. If you're heading for big numbers, the new N is no longer N / 2; Make a guess right in the middle of 1 and N/2 and go back to the beginning.   An algorithm that implements the strategy given above as a pseudocode, given below write according to the signature. Return of the opposite party in response to a specified estimate you can accept that there is a function called answer_student(prediction) that you can get. Do not write inside this function, you can use this function by calling it in your own algorithm.   Algorithm prediction (N)): // Input : the upper nerve of the range of the integer held by the opposite side (0..N) // Output: how many estimates are determined by the number held by the opposite side.

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter4: Selection Structures
Section: Chapter Questions
Problem 14PP
icon
Related questions
Question

Imagine playing a number guessing game. A side is a number from 0 to N
he's holding it, and the other side is trying to find that number by taking turns guessing. Number-holding side estimate
he has to offer one of the following three options in response to the party that did it:
1-Your guess is correct, you found the number I kept (Game Over).
2-Your estimate is wrong, but you are closer to the correct estimate than the previous estimate.
3-the wrong estimate and the correct estimate are further away than the previous estimate.
To find the estimated number in an environment where all the information is these, a
strategy will be followed:

Make a prediction (N/2) from the exact middle of N with 1

 

Begin:
Find out the answer to your guess. [answer=answer_ogren (guess)]
If the answer is equal to 1, the game is over, you can leave.
If the answer is equal to 2, you are going in the right direction, keep the forecast direction;
If you're heading for small numbers, the new N is now N/2.
Make a guess from the middle of 1 to N / 2 and go back to the beginning.
If you're heading for big numbers, the new 1 is now N/2.
Make a guess right in the middle of N / 2 and go back to the beginning.
If the answer is equal to 3, you are going in the wrong direction, change the direction of the guess;
If you're heading for small numbers, the new 1 is now N/2.
Make a guess right in the middle of N / 2 and go back to the beginning.
If you're heading for big numbers, the new N is no longer N / 2;
Make a guess right in the middle of 1 and N/2 and go back to the beginning.

 

An algorithm that implements the strategy given above as a pseudocode, given below
write according to the signature. Return of the opposite party in response to a specified estimate
you can accept that there is a function called answer_student(prediction) that you can get.
Do not write inside this function, you can use this function by calling it in your own algorithm.

 

Algorithm prediction (N)):
// Input : the upper nerve of the range of the integer held by the opposite side (0..N)
// Output: how many estimates are determined by the number held by the opposite side.

 

Expert Solution
steps

Step by step

Solved in 3 steps with 4 images

Blurred answer
Knowledge Booster
Probability Problems
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
Operations Research : Applications and Algorithms
Operations Research : Applications and Algorithms
Computer Science
ISBN:
9780534380588
Author:
Wayne L. Winston
Publisher:
Brooks Cole