Glossary: Data Structures and Algorithms in Java
top-k with a small heap
Also written: top k, top-k
Finding the k biggest items by keeping a min-heap of only k items: offer each item and `poll` the smallest whenever the heap grows to k + 1. It costs O(n log k), which beats sorting everything when k is small.