Which Data Structure Should be used for implementiong LRU cache?

Short Answer
Views 4831

Answer:

We use two data structures to implement an LRU Cache.

  1. Queue which is implemented using a doubly linked list. The maximum size of the queue will be equal to the total number of frames available (cache size).The most recently used pages will be near rear end and least recently pages will be near front end.
  2. A Hash with page number as key and address of the corresponding queue node as value. See How to implement LRU caching scheme? What data structures should be used?

Related Articles:

This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of Data Structure, click the links and dive deeper into this subject.

Join Our telegram group to ask Questions

Click below button to join our groups.