0
0
LLDsystem_design~10 mins

Why booking tests availability and concurrency 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 ensure the booking system checks availability before confirming.

LLD
if slot.is_available() and not slot.[1]():
    slot.book()
Drag options to blanks, or click blank then click option'
Ais_locked
Bis_full
Cis_reserved
Dis_open
Attempts:
3 left
💡 Hint
Common Mistakes
Using is_full instead of is_locked causes race conditions.
2fill in blank
medium

Complete the code to lock the slot before booking to handle concurrency.

LLD
def book_slot(slot):
    if slot.[1]():
        slot.lock()
        slot.book()
Drag options to blanks, or click blank then click option'
Ais_locked
Bis_booked
Cis_reserved
Dis_available
Attempts:
3 left
💡 Hint
Common Mistakes
Locking without checking availability leads to errors.
3fill in blank
hard

Fix the error in the concurrency control to prevent double booking.

LLD
def book_slot(slot):
    if slot.is_available():
        slot.[1]()
        slot.book()
Drag options to blanks, or click blank then click option'
Areserve
Bunlock
Clock
Dcancel
Attempts:
3 left
💡 Hint
Common Mistakes
Unlocking before booking causes race conditions.
4fill in blank
hard

Fill both blanks to implement optimistic concurrency control in booking.

LLD
def book_slot(slot, version):
    if slot.version == [1]:
        slot.book()
        slot.version = [2]
Drag options to blanks, or click blank then click option'
Aversion
Bversion + 1
Cversion - 1
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Decrementing version causes incorrect concurrency control.
5fill in blank
hard

Fill all three blanks to implement a thread-safe booking with locking and availability check.

LLD
def safe_book(slot):
    with slot.[1]():
        if slot.[2]():
            slot.[3]()
Drag options to blanks, or click blank then click option'
Alock
Bis_available
Cbook
Dunlock
Attempts:
3 left
💡 Hint
Common Mistakes
Checking availability outside lock causes race conditions.