Search for question
Question

3. [33 points] Create a file called, hw1_3_guess_flow_xxx, where xxx is as above. In this file, draw a flowchart to solve the following problem. Try to design an algorithm that enables the computer to always win the game. Use the same guidance and conventions described in problem 1.

• Create a flowchart for a program that plays, "Guess My Number" with the user. The human user secretly picks a number between 1 and 100 and writes it on a piece of paper. The computer must try to guess it. The human user must answer each guess, truthfully, with one of 3 answers:

- yes (if the computer's guess is correct) - Computer Wins!

- low (if the guess is too low)

- high (if the guess is too high)

• One simple approach might be to ask, "is it 1?", "is it 2?" and so on. However, if the

user had chosen 100 as their number, this approach would take 100 guesses! (On the

average, if the user choses randomly, this approach would take about 50 tries.)

• And, there is one more rule:

• The computer is limited to 7 guesses.

• After 7 guesses - unless the final guess was correct the game is over and the

computer has lost! Try to devise a winning algorithm for the computer.

• Note: You should NOT implement the Binary search algorithm. Thus, assuming that

the number of guesses is always less than or equal 7 is incorrect.