Algorithms and Data Structures · Middle · Question 68 of 75

Which problem is solved by keeping the k most recent values in a fixed-size ring buffer?

Explanation

A ring buffer overwrites the oldest entry when it's full, with O(1) writes and no shifting. The k largest values need a heap, not a ring buffer.

Further reading

Problem with a question

Algorithms and Data Structures · Middle · question 68

Test yourself

Take the Algorithms and Data Structures · Middle quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz