Bird
0
0
LLDsystem_design~10 mins

Why elevator design tests state machines in LLD - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define the initial state of the elevator.

LLD
elevator_state = '[1]'
Drag options to blanks, or click blank then click option'
ADOOR_OPEN
BMOVING
CIDLE
DMAINTENANCE
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing MOVING as initial state, which is incorrect because elevator starts idle.
2fill in blank
medium

Complete the code to transition the elevator state to moving when a request is received.

LLD
if request_received:
    elevator_state = '[1]'
Drag options to blanks, or click blank then click option'
AMOVING
BIDLE
CDOOR_OPEN
DSTOPPED
Attempts:
3 left
💡 Hint
Common Mistakes
Setting state to IDLE after request, which means no movement.
3fill in blank
hard

Fix the error in the state transition when the elevator reaches the floor.

LLD
if elevator_state == 'MOVING' and at_floor:
    elevator_state = '[1]'
Drag options to blanks, or click blank then click option'
AMOVING
BIDLE
CMAINTENANCE
DDOOR_OPEN
Attempts:
3 left
💡 Hint
Common Mistakes
Setting state to IDLE immediately, skipping door opening.
4fill in blank
hard

Fill both blanks to complete the state machine transition for closing doors and going idle.

LLD
if elevator_state == 'DOOR_OPEN' and door_closed:
    elevator_state = '[1]'
if elevator_state == '[2]' and no_requests:
    elevator_state = 'IDLE'
Drag options to blanks, or click blank then click option'
AMOVING
BDOOR_OPEN
CIDLE
DSTOPPED
Attempts:
3 left
💡 Hint
Common Mistakes
Setting state to IDLE immediately after door closes without checking requests.
5fill in blank
hard

Fill all three blanks to complete the dictionary for elevator states and their descriptions.

LLD
state_descriptions = {
    '[1]': 'Elevator is idle and waiting',
    '[2]': 'Elevator is moving between floors',
    '[3]': 'Elevator doors are open'
}
Drag options to blanks, or click blank then click option'
AIDLE
BMOVING
CDOOR_OPEN
DMAINTENANCE
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up state names and descriptions.