Question: THE FOLLOWING CODE NEEDS TO BE WRITTEN IN MIPS ASSEMBLY LANGUAGE. -Write the code to guess the player's hidden number in no more than 20
THE FOLLOWING CODE NEEDS TO BE WRITTEN IN MIPS ASSEMBLY LANGUAGE.
-Write the code to guess the player's hidden number in no more than 20 guesses using the Goldilocks approach. Following each guess, the player will respond with an indication of whether the guess was too high, too low, or just right.
Algorithm:
The player will be asked to think of a number in the range of 0-1,000,000 exclusive. Your code will then use a binary search to determine the hidden number. For each guess, divide the range of remaining valid guesses in half and ask the number at the midpoint of the range. Depending on the players response to the guess, modify the range accordingly or terminate the program. Continue guessing until either the number has been guessed correctly or the valid range is empty. If the number has not been guessed in 20 attempts, inform the player that you suspect foul play.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
