← Back to Games

🔬 Miniature Forge

Find K Smallest Elements Using Max-Heap of Size K

Max-Heap (Size K)
⚙️ Settings
📊 Stream
Numbers will appear...
🔬 K Smallest
💡 Algorithm
Maintain MAX-heap of size K.
If new num < heap max:
• Remove max (too large)
• Insert new num
Heap contains K smallest!