Question discussion

Which combination of data structures is typically used to implement an LRU (Least Recently Used) cache with O(1) get and put operations?

1752Medium DSSSB TGT Computer Science 0 replies 1 views
0

Which combination of data structures is typically used to implement an LRU (Least Recently Used) cache with O(1) get and put operations?

  • AA hash map and a doubly linked list
  • BA stack and a queue
  • CA binary search tree and an array
  • DA min-heap and a stack
Correct answer: A

Explanation

The hash map gives O(1) lookup while the doubly linked list keeps the usage order and lets a node be moved to the front in O(1).

Discussion 0

Nobody has replied yet. Start the discussion!