Bird
Raised Fist0

In which scenario is Implementation B more advantageous?

hard⚖️ Approach Comparison Q8 of Q15
OOP & Design Patterns - Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)
Two parking lot implementations use different approaches: Implementation A uses a centralized ParkingLot class managing all spots; Implementation B uses distributed Level classes each managing their own spots. In which scenario is Implementation B more advantageous?
AWhen the parking lot has many levels and needs concurrent spot allocation
BWhen the system requires a global view of all spots at all times
CWhen spot allocation logic is simple and uniform across levels
DWhen the parking lot is small with only one level
Step-by-Step Solution
Solution:
  1. Step 1: Compare centralized vs distributed management

    Centralized manages all spots in one place; distributed delegates to levels.
  2. Step 2: Analyze concurrency needs

    Distributed management allows parallel spot allocation per level, reducing contention.
  3. Step 3: Evaluate scenarios

    Small single-level lots (A) don't benefit from distribution; simple uniform logic (C) favors centralization; global view (B) easier with centralized.
  4. Final Answer:

    Option A -> Option A
  5. Quick Check:

    Distributed design suits multi-level concurrency [OK]
Quick Trick: Distributed management enables concurrency in multi-level lots [OK]
Common Mistakes:
MISTAKES
  • Choosing centralized for multi-level concurrency
  • Ignoring concurrency benefits of distribution
  • Assuming global view requires distributed design
Trap Explanation:
PITFALL
  • Candidates often overlook concurrency advantages of distributed management in large systems.
Interviewer Note:
CONTEXT
  • Evaluates trade-offs between centralized and distributed design in scalability.
Master "Design a Parking Lot - LLD with OOP (Classes, Patterns, Extensibility)" in OOP & Design Patterns

2 interactive learning modes - each teaches the same concept differently

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More OOP & Design Patterns Quizzes