English

Min-heap priority

Maintain the smallest value at a heap root while showing every repair.

Adult planning suggestion: about 9–12 · Logic & rule checking

Players
1–4 cooperatively
Time
15–25 minutes
Materials
Seven numbered array slots and number cards 5,2,7,1,3

Prepare

Number array positions from 1. The parent of position i is floor(i/2); its children are 2 i and 2 i+1 when those slots exist. A min-heap requires every parent value to be at most either child. Siblings need not be sorted.

Play

Insert 5,2,7,1,3 in that order. Each new card goes in the next unused array slot. Swap it upward with its parent while smaller; stop at the root or a parent no larger than it. Write the full array after each insertion.

Worked example

The arrays are [5], [2,5], [2,5,7], [1,2,7,5], [1,2,7,5,3]. Inserting 1 swaps past 5 and 2. Inserting 3 needs no swap because its parent 2 is already smaller.

Finish and check

To remove the minimum, record the root 1, move last value 3 to the root and delete its former last slot. Compare the two children and swap with the smaller one only if that child is smaller. The result is [2,3,7,5]. Do not remove a middle slot or sort all cards into a row.

Adaptation and limits

Remove and record the remaining roots in the same way:2,3,5,7. Finish when all five outputs read 1,2,3,5,7 and each intermediate array satisfies the parent rule. Equal cards may stop without swapping; a partner audits every parent-child pair.

Purpose, observation and provenance

Within this activity: Maintain the smallest value at a heap root while showing every repair.

After each operation, ask the checker to compare every parent with its children rather than sort the sibling values.

Our rules, examples and printable diagrams are separately prepared. The earliest inventor of the broader mechanism is not established here.

VisuAlgo: Binary Heap — Reference describes heap structure and operations. Our example uses the minimum-first comparator rather than its maximum-first illustrations.

Secondary practice: Cooperation and explaining a check.

For a class of 30, use ten groups of three. Prepare one player-material set per group and keep the host key with the adult. Rotate operator, recorder and checker after each worked example; a reader or scribe may help without choosing answers. Avoid public ranking or diagnostic labels.

Age bands are planning suggestions. Background references may address older learners and do not validate suitability for this age band. Goals describe observable actions, not measured long-term gains or institutional endorsement.

Free alternative: Copy the supplied grids, labels and cards onto reused paper. No specialist product is needed. Adults may prepare pieces or act as a scribe.

Printable materials

Preview at 100% scale, with browser headers and footers off. Cut with suitable help. Keep host keys separate. This is a manual tabletop kit, not an online opponent, automatic judge or solver.

Rules to keep beside the materials

  1. Number array positions from 1. The parent of position i is floor(i/2); its children are 2 i and 2 i+1 when those slots exist. A min-heap requires every parent value to be at most either child. Siblings need not be sorted.
  2. Insert 5,2,7,1,3 in that order. Each new card goes in the next unused array slot. Swap it upward with its parent while smaller; stop at the root or a parent no larger than it. Write the full array after each insertion.
  3. The arrays are [5], [2,5], [2,5,7], [1,2,7,5], [1,2,7,5,3]. Inserting 1 swaps past 5 and 2. Inserting 3 needs no swap because its parent 2 is already smaller.
  4. To remove the minimum, record the root 1, move last value 3 to the root and delete its former last slot. Compare the two children and swap with the smaller one only if that child is smaller. The result is [2,3,7,5]. Do not remove a middle slot or sort all cards into a row.
  5. Remove and record the remaining roots in the same way:2,3,5,7. Finish when all five outputs read 1,2,3,5,7 and each intermediate array satisfies the parent rule. Equal cards may stop without swapping; a partner audits every parent-child pair.

Min-heap priority — play materials

5
2
7
1
3
Array slot1234567
Value
Insert/removeArray after repairsOutput
________________________
________________________
________________________
________________________
________________________
________________________
________________________
________________________
________________________
________________________

Host check — keep private until finished

After inserts [1,2,7,5,3]; first removal [2,3,7,5]; output 1,2,3,5,7.

These are model answers or legal examples, not records of an experiment or learner outcomes.

Related activities

Activity library · Nested bracket stack