LFU Full Form
LFU stands for Least Frequently Used. It is a cache algorithm that is used to optimize the memory of the computer. In this algorithm, the system keeps a track of how many times a block is referred in memory. When the cache memory is completely filled and demands more room, then the item with the lowest reference frequency is removed.
Three operations performed by LFU are – Set (insert ), Retrieve(lookup), Evict(delete).
A simple approach is that we assign a counter to each block that appears in memory. Now, every time the block reappears the counter increases by one. When cache memory is completely filled and a new block has to be inserted then the block with the minimum counter value will be removed from the cache memory and the new value will be inserted. When the block is removed from cache memory then the counter for that block is initialized to zero.
- Can Follow the FIFO Method i.e. First in First Out.
- Min Heap can be used to implement this algorithm in logarithmic time complexity.
- It is very systematic in those cases where the access pattern for cache memory doesn’t change too often.
- Useful to find an item when data is repeated.Example – It is used in the mobile keyboard for suggesting the word and hence after some use it starts suggesting those words which are more often used.
- In LFU old page along with frequency is checked for that page.
- New items inserted in the cache will be removed very soon as they will have low count but they can be used very frequently again.
- Belady’s anomaly can also occur.