Skip to content
BytePatterns

Two Heaps & K-Way Merge

Two heaps that lean on each other, and one that merges k sorted streams.

Two Heaps & K-Way Merge progress0 / 4
  1. Two Heaps: Running MedianTwo heaps face each other, and the middle sits between their roots.6m
  2. K-Way MergeOne heap of k heads turns k sorted lists into one.6m
  3. Top K in a StreamCount once, then let a k-sized heap keep only the winners.6m
  4. Sliding Window MedianYou cannot dig a value out of a heap — so mark it dead instead.7m

Quiz yourself: 3 questions from this module

1 / 3

Which heap holds the lower half?