REI Systems Interview Question: Unexpected question - Guess t... | Glassdoor

## Interview Question

Software Engineer Interview Herndon, VA

# Unexpected question - Guess the number I am thinking of

which is between 1 and 100 by asking minimal Yes or No questions.

6

Binary search algorithm, keep cutting problem in half. (Assuming it is an integer) I can do it in 7 questions. Let's say the number is 1, what is the longest it would take me dividing in half? Is it Greater than 50(n), &gt; 25(n), &gt; 12(n), &gt;6(n) &gt;3(n), so not it is 1,2,3..
is it 3 (n), is it 2(n), then it is one. 7 questions. (still works if you ask 12.5 rather than 12)

Now if you want to impress the computer guy ask your questions in true binary. The 7th bit is worth 64, so only 7 bits need to be used to count to one hundred. Ask what each of the seven bits is set to, write them down and then add it up. (yes/no question, if this number was represented in binary, is first bit a 1).

So I did not think of this last answer until after I had thought out the first, then I thought it would be a funny joke to ask him in binary, then I realized it would actually work. That is the kind of think-out-loud thought process an interview wants to see.