Determine a Player's Number

A player is asked by a host to think of a number between 0 and 31. In a round, the host asks a single question of the player about the number. The problem is to determine what questions the host should ask of the player so that the number is guaranteed to be determined by the host in the minimum number of rounds.



The question might be of the form Is your number 11?. The applet above simulates this type of question. The answer to such a question, if no, eliminates a single number. This is shown by clicking on a number and watching the number's cell go dark. In the worst case, the number of questions needed to succeed is 31.



The question might be of the form Is your number less than 11? If the guessed number is middle of a range of unknown numbers, the answer to a single question can eliminate the need to check 1/2 of the unknown numbers. This results in a worst case number of questions equal to 5. The dark cells either have been checked or need not be checked.



Another variant of the binary search applet.