Coding & Algorithms (DSA)
Heaps & Priority Queues
6 practice questions. Free questions open a full answer guide; the rest unlock with Pro.
- How would you maintain a running median over a stream of incoming values, and why is a two-heap design the standard approach rather than keeping a sorted list?
- What is a binary heap, and how do you use one to find the k largest elements in a stream of numbers?Go Pro
- What is a priority queue, when have you used one, and how does it differ from a regular FIFO queue?Go Pro
- Why is a heap usually the right structure for a priority queue or a top-k problem rather than a sorted list or a balanced BST, and what does it actually cost per operation?Go Pro
- How would you efficiently merge k sorted streams into one sorted output, and why is a heap-based approach better than repeatedly scanning for the next smallest?Go Pro
- You need the k largest elements out of a very large stream of numbers. Compare using a heap, sorting, and quickselect, and tell me how the relationship between k and n drives your choice.Go Pro
Want questions matched to your role? Paste a job title, job description, or CV for a personalized set, or go Pro to unlock the full bank.