Bird
Raised Fist0

What is the time complexity trade-off when implementing the working set model with a sliding window of size \( \tau \) for page reference tracking in a system with \( n \) pages?

medium🪤 Complexity Trap Q5 of Q15
Operating Systems - Thrashing - Working Set Model & Prevention
What is the time complexity trade-off when implementing the working set model with a sliding window of size \( \tau \) for page reference tracking in a system with \( n \) pages?
AO(n) per page reference due to scanning the entire window for each update.
BO(\tau) per page reference because the window size \( \tau \) limits the tracking scope.
CO(1) amortized per page reference using efficient data structures like queues and hash maps.
DO(n \times \tau) overall since each page must be checked against the entire window.
Step-by-Step Solution
Solution:
  1. Step 1: Understand working set tracking

    The working set model tracks pages referenced within a recent window \( \tau \).
  2. Step 2: Analyze complexity

    Naively scanning the window per reference is O(\tau), but efficient data structures (queues + hash maps) allow O(1) amortized updates.
    A: O(n) per page reference due to scanning entire window is incorrect.
    B: O(\tau) per page reference ignores data structure optimizations.
    D: O(n \times \tau) overestimates complexity.
  3. Final Answer:

    Option C -> Option C
  4. Quick Check:

    Efficient data structures enable O(1) amortized updates [OK]
Quick Trick: Use queues and hash maps for O(1) amortized working set updates [OK]
Common Mistakes:
MISTAKES
  • Assuming scanning entire window per reference (O(\tau))
  • Confusing total pages with window size in complexity
  • Ignoring data structure optimizations
Trap Explanation:
PITFALL
  • Candidates often forget amortized cost improvements from data structures and assume naive scanning.
Interviewer Note:
CONTEXT
  • Tests understanding of complexity trade-offs in working set implementation.
Master "Thrashing - Working Set Model & Prevention" in Operating Systems

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 Operating Systems Quizzes