I'm working on a question from a test in Data Structures, I need to suggest a data structure S that will comply with the follwing requirements:
NOTE: S should allow multiple values with the same keys to be inserted
- INSERT(S, k): insert object with key- kto- Swith time complexity- O(lg n)
- DELETE_OLD(S): Delete the oldest object in- Swith time complexity- O(lg n)
- DELETE_OLD_MIN(S): Delete the oldest object that has the lowest key in- Swith time complexity- O(lg n)
- MAX_COUNT(S): Return the key with the maximum frequency (most common key in- S) with time complexity- O(lg n)
- FREQ_SUM(S,z): Finding two keys (a and b) in- Ssuch that- frequency.a + frequency.b = zwith time complexity- O(lg n)
I tried some ideas but could not get passed the last two.
EDIT: The question A data structure traversable by both order of insertion and order of magnitude does NOT answer my question. Please do not mark it as duplicate. Thank you.
EDIT #2: Example for what freq_sum(S,z) does:
Suppose that one called freq_sum(S,5) over the data structure that contains: 2, 2, 2, 3, 4, 4, 4, 5, 5
The combination 2 and 5 could be a possible answer, becuase 2 exists 3 times in the structure and 5 exists 2 times, so 3+2=z
 
     
    