<aside> 🏔️

L7 — Use Heaps! covers the heap data structure (definition, two properties), adding elements (percolate up), priority queues, removing the minimum (percolate down), array implementation with index formulas and bit-shift optimisations, Java code for a heap-based priority queue, time complexity analysis, and heap sort.

</aside>

📋 At a Glance


1. Heaps — Definition

A (min-)heap is a binary tree satisfying two constraints:

  1. Complete tree — every level above the lowest is fully occupied, and the lowest level is filled left to right
  2. Heap order — each child has a value greater than or equal to its parent