Back to Projects

Computer Science Coursework

CPSC 221 Heaps Lab

A UBC CPSC 221 C++ lab focused on array-backed heap implementation and heap operation tests. The work centers on heapify, upheap/downheap behavior, priority-queue ordering, and index arithmetic.

Period

Mar 2025

Tools / Tech

C++HeapsPriority QueuesHeapifyUpheapDownheapTesting

Why I built it

The lab was useful for practicing how a tree-shaped invariant can be stored and maintained inside a compact array representation.

Links

What it includes

  • Implements heap operations on an array-backed structure.
  • Practices heapify, upheap, downheap, and priority ordering.
  • Uses tests to catch indexing and invariant mistakes.

What I worked on

  • Completed the heap implementation exercises myself in C++.
  • Debugged parent/child index calculations and heap invariants.
  • Connected priority-queue behavior to low-level array operations.

What I Learned

  • Learned how off-by-one errors can break heap behavior.
  • Practiced reasoning about implicit tree structures.
  • Improved confidence with testing compact data representations.