K-Way Merge

Interactive visualizations demonstrating different data structures and algorithms for merging multiple sorted streams.

Linear Scan

A simple approach that scans all K candidates at each step to find the smallest. Serves as the baseline for comparison.

O(K) per step

Min-Heap Merge

Use a binary Min-Heap to select the smallest element.

O(log K) per step

Tree of Winners

Uses a tournament tree where the smallest element rises to the root through a series of matches at each level.

O(log K) per step (less comparisons)

Tree of Losers

A variation of the tournament tree where losers are stored at internal nodes, simplifying the replay path to the root.

O(log K) per step (less comparisons, less memory accesses)