Min-heap of fixed size
Find top k scores
Maintain a heap of size k while scanning scores so the final heap contains the k largest values.
Advanced Topics in Computer Science
Students study priority queues and the heap structure that supports efficient access to the highest or lowest priority item.
Unit Focus
This unit connects tree ideas to array-based implementation and prepares students for scheduling, graph algorithms, and heapsort.
Practice Work
Implement a binary heap-backed priority queue.
Use a priority queue to simulate task scheduling or emergency triage.
DSA Assignment Bank
Code Scholars provides structured assignments, implementation support, edge-case review, and runtime analysis coaching so students learn the concept rather than only memorizing a solution.
Min-heap of fixed size
Maintain a heap of size k while scanning scores so the final heap contains the k largest values.
Priority queue merge
Use a priority queue to merge several sorted lists by repeatedly taking the smallest current value.
Two heaps
Use a max-heap for the lower half and a min-heap for the upper half to report the median after each insertion.
Heap plus queue
Arrange repeated tasks so identical tasks are separated by a cooldown, using counts and waiting times.
Heap or selection
Return the k points closest to a center point and compare max-heap and sorting approaches.
Priority queue comparator
Order patients by severity, arrival time, and name, then explain comparator tie behavior.
Greedy heap
Repeatedly combine the two smallest lengths and prove why the heap supports the greedy choice efficiently.
Fixed-size heap
Process values one at a time and report the kth largest value after each update.
Bottom-up heap construction
Transform an array into a heap using percolate-down from the last internal node.
Percolate up
Insert values into a binary heap and show the array after each percolate-up step.
Percolate down
Remove the root, move the last value to the root, and show each swap needed to restore heap order.
Heap sort phases
Build a max-heap, repeatedly move the max to the end, and restore heap order in the remaining prefix.
Priority queue window
Choose one value from each sorted list so the range is as small as possible.
Min-heap by end time
Given meeting intervals, compute the minimum number of rooms needed by tracking earliest ending meetings.
Max-heap by frequency
Rearrange characters so no adjacent characters match, or explain why it is impossible.
Comparator design
Create a comparator for assignments ordered by due date, priority, and student name.
Data structure tradeoff
Explain which structure is better for frequent insertions with repeated highest-priority removals.
Priority queue frontier
Maintain frontier nodes ordered by best known distance and skip stale entries safely.
Heap for k-sorted data
Sort data where each item is at most k positions from its correct location.
Min-heap by time
Simulate sending notifications by always processing the earliest scheduled event first.
Array representation
Given parent and child index formulas, find the off-by-one error in a heap implementation.
Structural invariant
Check whether an array satisfies min-heap order and explain why completeness is implicit in array storage.
Heap encapsulation
Build offer, poll, peek, size, and isEmpty while hiding the internal array representation.
Heap with visited pairs
Given two sorted arrays, find the largest k pair sums without generating every pair.
Greedy min-heap
Assign each new task to the currently least-loaded student team and analyze when this greedy plan is reasonable.
Runtime analysis
Given n inserts and m removals, compute the total asymptotic cost and compare with repeated sorting.
Heap plus lazy deletion
Support changing player scores while avoiding incorrect stale heap entries.
Discrete event simulation
Process simulation events ordered by time and add future events as the simulation runs.
DSA decision
Choose between queue, sorted ArrayList, TreeMap, and heap for several priority-based scenarios.
DSA support
Create a heap assignment requiring manual traces, implementation, comparator design, and runtime comparison.
Work through the concepts, code, edge cases, and runtime analysis with 1:1 guidance.