AlgoScope

LFU Cache

Data structureadvancedCaches and Filters

Evicts the least frequently used entry, breaking ties by recency.

Decision · step 3 of 10LRU Cache: LFU: the oldest entry survives because it is the most used
1:10 x2✓head

get 1: a hit, value 10. Its count goes from 1 to 2, which moves it up past every entry with a lower count and to the front of the entries that share its new count.

Open in the player →or start at step 3

What you will see

Frequency buckets; an access moves the node up one bucket.

How lru cache works →

Cost

getO(1)
putO(1)
SpaceO(capacity)

How you work with it here

play it through, step one change at a time, scrub to any step, run it on your own input, try operations in any order.

Screen readers: Each element is an accessibility element with position, value and state; structural changes are announced per step.

Reduced motion: Elements appear at their destination with a crossfade; no travel longer than the element's own size.

Before this

Related

Taught by the same lesson

LRU Cache covers these too, in the same run.