Abstract
A Heap is a specialized tree-based data structure that satisfies strict structural shape invariants and relative priority ordering properties. Bypassing the pointer overhead of traditional dynamic trees, it serves as the standard physical implementation layer for the Priority Queue ADT.
- Category: Complete Tree Index Structure
- Primary Backbone: Bounded flat contiguous arrays without explicit link pointers.
- Key Advantage: Fast constant-time root access paired with predictable mutation paths.
Core Structural Constraints
A valid Binary Heap structure must simultaneously satisfy three core geometric rules:
- Binary Tree Property: Every individual node inside the hierarchy is restricted to a maximum of two children (maintaining 0, 1, or 2 outgoing branches).
- Heap Property: For any two nodes and , if functions as the structural parent of child node , then the priority value of must be higher than or equal to the priority value of .
- Shape Property: The structure must operate as a Complete Tree. Every horizontal level of the tree must be fully populated with nodes except for the bottom-most active level, which must be packed sequentially from left to right without internal gaps.
Heap Topological Classifications
Priority rankings are determined directly by evaluating element key weights. Because relative priorities define all branch paths, duplicate keys are permitted throughout the layout; internal priority ties are resolved arbitrarily.
| Architectural Dimension | Min-Heap Configuration | Max-Heap Configuration |
|---|---|---|
| Structural Ordering | ||
| Root Node Assignment | Minimum global value (Highest Priority) | Maximum global value (Highest Priority) |
| Priority Processing Logic | Smaller key weights assume higher rank | Larger key weights assume higher rank |
Data Structure Operations
Peek()
Identifies and returns the absolute highest-priority element tracking within the collection.
- Time Complexity: strictly constant time.
- Algorithmic Logic: The Heap Property guarantees that the highest-priority element always resides at the root position.
Push(element) (Element Insertion)
Appends a new value to the structure while maintaining the Shape Property and the Heap Property.
- Time Complexity: worst-case boundary path.

Algorithm 39 Heap Element Insertion (Bubble Up)
procedure Push()
while do
if HasHigherPriority() then
Swap()
else
break
Pop() (Highest-Priority Extraction)
Removes the highest-priority element from the container while preserving heap properties.
- Time Complexity: worst-case boundary path.

Algorithm 40 Heap Root Extraction (Trickle Down)
procedure Pop()
if then
return
while do
if and HasHigherPriority() then
if HasHigherPriority() then
Swap()
else
break
Child Swap Selection Logic
When trickling an element down, the engine must swap with the highest-priority child branch. Swapping with the weaker child would violate the Heap Property by leaving a child node with higher priority than its newly assigned parent.
Flat Array Implementation Mapping
Because heaps satisfy the strict structural definition of a complete tree, they map directly into sequential hardware memory arrays without requiring pointers or leaving empty slots between items.

For an entry element located at array coordinate position under standard 0-based indexing, coordinate translations map to the following mathematical formulas:
- Parent Offset Location:
- Left Child Offset Location:
- Right Child Offset Location:
- Next Available Shape Slot: Coordinates directly to array index (where represents the total active element count).
Architectural Complexity Summary
Peek()Operational Latency: constant time execution.Push()Insertion Latency: bounding log steps.Pop()Extraction Latency: bounding log steps.- Total Structural Space Footprint: Exactly flat contiguous allocations.