Bird
Raised Fist0

What is the time complexity of implementing LRU page replacement using a hash map and a doubly linked list for n page references and k frames?

medium🪤 Complexity Trap Q5 of Q15
Operating Systems - Page Replacement - FIFO, LRU, Optimal Algorithm
What is the time complexity of implementing LRU page replacement using a hash map and a doubly linked list for n page references and k frames?
AO(n), because each page reference is handled in constant time
BO(n log k), due to searching in a balanced tree structure
CO(nk), because each reference may require scanning all frames
DO(n + k), combining initialization and reference handling
Step-by-Step Solution
Solution:
  1. Step 1: Analyze data structure operations

    Hash map provides O(1) lookup, doubly linked list allows O(1) insert/delete. Each of n references handled in O(1), total O(n).
  2. Final Answer:

    Option A -> Option A
  3. Quick Check:

    Hash + linked list yields O(1) per reference [OK]
Quick Trick: Hash + linked list = O(1) per reference [OK]
Common Mistakes:
MISTAKES
  • Assuming O(nk) due to scanning frames
  • Confusing with tree-based structures
  • Ignoring constant-time linked list operations
Trap Explanation:
PITFALL
  • Candidates often think scanning frames is needed, missing the O(1) update via hash and linked list.
Interviewer Note:
CONTEXT
  • Tests understanding of LRU efficient implementation complexity.
Master "Page Replacement - FIFO, LRU, Optimal Algorithm" 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