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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education