Bird
0
0

Analyze this pseudocode for updating a book record:

medium📝 Analysis Q4 of 15
LLD - Design — Library Management System
Analyze this pseudocode for updating a book record:
if book_id exists:
    update book details
    return 'Updated'
else:
    return 'Book not found'

What will be the output if the book_id is invalid?
AUpdated
BBook not found
CError: Invalid input
DNo action taken
Step-by-Step Solution
Solution:
  1. Step 1: Check book_id existence

    The pseudocode first checks if the book_id exists in the system.
  2. Step 2: Handle invalid book_id

    If the book_id is invalid or does not exist, the else block executes, returning 'Book not found'.
  3. Final Answer:

    Book not found -> Option B
  4. Quick Check:

    Invalid book_id triggers else condition [OK]
Quick Trick: Invalid IDs return 'Book not found' message [OK]
Common Mistakes:
MISTAKES
  • Assuming update happens even if book_id is invalid
  • Confusing error messages with return values
  • Ignoring the else condition in pseudocode

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes