Data structure for cache design with efficient insertion, deletion and extraction of the highest value

I need to implement a cache with regular cache operations, along with the ability to quickly retrieve the maximum element from the cache.

Can you suggest data structures to implement this?

I thought of using a hash map along with a list to keep the minimum element.

Suggest other approaches with better complexity.

+3
source share
2 answers

heap is great for quickly restoring the maximum element.

+6
source

, lookaside, . N (- 8 ), ( ) :

[list N]
[list N*2]
[list N*4]
[list N*8]
...

. , (S), LOG2 (S/N) , , . ( ) , , , .

+4

Source: https://habr.com/ru/post/1715249/


All Articles