Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

One In A Million Your first MIPS assembly program is to write the code to guess the players hidden number in no more than 20

One In A Million

Your first MIPS assembly program is to write the code to guess the players 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.

Example Run

Think of a number in the range of 1-1000000. I will attempt to guess your number. Respond to my guesses with one of the following: H if the guess is too high L if the guess is too low E if the guess is correct

Guess #1: 500000 ?

L

Guess #2: 750000 ?

H

Guess #3: 625000 ?

L

...

Guess #18: 666666 ?

E

I got it in 18 guesses! Program terminated.

NO HLL, MIPS Assembly Language Only

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions