Bird
0
0

What is the primary logical error?

medium📝 Analysis Q6 of 15
LLD - Design — Elevator System
In a SCAN algorithm implementation, the disk head is at 40 and requests are [10, 20, 30, 50, 60]. The code incorrectly services requests in ascending order regardless of head direction. What is the primary logical error?
AThe algorithm services requests only in descending order
BThe algorithm reverses direction too early before reaching the disk end
CThe algorithm ignores the current head direction and always sorts requests ascending
DThe algorithm does not include the current head position in servicing
Step-by-Step Solution
Solution:
  1. Step 1: Understand SCAN behavior

    SCAN services requests in the direction of head movement, then reverses at disk end.
  2. Step 2: Identify error in code logic

    Servicing requests always in ascending order ignores the head's current direction, violating SCAN's principle.
  3. Step 3: Correct approach

    Requests should be serviced in ascending order when moving up, descending when moving down.
  4. Final Answer:

    The algorithm ignores the current head direction and always sorts requests ascending -> Option C
  5. Quick Check:

    SCAN must consider head direction when ordering requests [OK]
Quick Trick: SCAN must respect head direction when ordering requests [OK]
Common Mistakes:
MISTAKES
  • Sorting requests only ascending without direction check
  • Not reversing direction at disk ends
  • Skipping requests on return path

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes