Most developers never implement a hash map, a heap, or a binary search tree. They reach for std::unordered_map , std::priority_queue , std::map , and move on. That is correct for shipping code. But it leaves a gap. When you have only ever used a heap, "k-th largest in O(n log k)" is a magic phrase. When you have built one, it is obvious: a size-k heap, push, pop when it overflows, done. The trick is to build each structure exactly once, with tests checking every step, and then go back to using t