1
$\begingroup$

You are designing an elevator controller for a building with 25 floors. The controller has two inputs: UP and DOWN. It produces an output indicating the floor that the elevator is on. There is no floor 13. What is the minimum number of bits of state in the controller?

Answer: The system has at least five bits of state to represent the 24 floors that the elevator might be on.

Can someone explain how this comes to be?

$\endgroup$
  • 1
    $\begingroup$ Welcome to CS.SE! What are your thoughts? What attempt have you made? We want you to make a serious effort to solve your exercise before posting here, and to show us in the question what approaches you've considered/tried -- this helps us give you better answers. $\endgroup$ – D.W. Oct 20 '15 at 4:37
3
$\begingroup$

Well, as binary typically goes, one bit represents two possible values: 0 and 1. With two bits there are a possible combination of four values: 0, 1, 2, 3 in hex/decimal/octal or 00, 01, 10, 11 in binary. Expand out to three bits you have eight values. 0 to 7 or 000, 001, 010, 011, 100, 101, 110, and 111.

Expand upon this and you'll have your understanding.

For reference (with a nice animation for counting on any base): https://www.mathsisfun.com/binary-number-system.html

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.