Question: The answer should just be within the findNumber method. make sure the code makes 2log(n) guesses. only write code for findNumber method that meets all


The answer should just be within the findNumber method. make sure the code makes 2log(n) guesses. only write code for findNumber method that meets all the requirements above about the limits and number of guesses.
"Guessing Game" is a game with two parties: the "chooser" and the "guesser". The "chooser" picks a natural number larger than zero, and the guesser must guess what it is. Note that there is no upper bound on the number the chooser can pick. Write Java code for a method findNumber which simulates the "guesser" in a guessing game by making a series of guesses and returning the correct answer. If the number chosen is n, then your code may make at most 2lg(n) guesses. Your method will be given a Chooser object with the single method public String guess (BigInteger number) which returns one of "correct" (your answer is correct), "higher" (the correct answer is higher), and "lower" (the correct answer is lower) based on the answer and the provided guess. 1- public static BigInteger findNumber(Chooser c) { Write Java code for findNumber(), a method that simulates the "guesser" in a guessing game by making a series of guesses and returning the correct answer. You should not have to bruteforce the number one-by-one. If the number chosen is n > 2, your code may make at most 2 log2(n) guesses
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
