Topic notebook / 06

Heaps & priority

A heap returns the smallest or largest priority without sorting every item after every change.

What to look for

  • Choose the priority, not just the stored value.
  • Remember Python heapq is a min-heap.
  • Keep only the candidates you still need.

Work through a question

3 available

Where this leads

Return to the roadmap to try a different kind of problem.