2. Prerequisite: An Introduction to the Tree Data Structure

Before we can understand the Heap, we must first be familiar with its underlying structure: the Tree. In computer science, a tree is a widely used data structure that simulates a hierarchical structure, with a set of connected nodes.

Core Components

Every tree is composed of a few fundamental components:

Consider the tree structure below:

Hierarchical Terminology

The relationships between nodes in a tree are described using terminology borrowed from family trees:

Structure and Depth

We can measure the structure of a tree in several ways:

Focus on the Binary Tree

While a node in a tree can have any number of children, our focus for understanding heaps will be on a specific type: the Binary Tree.

Binary Tree is a tree data structure in which each node has at most two children, which are referred to as the left child and the right child.

The reason we focus on Binary Trees is that the Heap data structure, which is the engine of Heap Sort, is a specialized type of Binary Tree. Mastering this concept is a fundamental step toward understanding heaps.


Revision #1
Created 2025-09-24 08:19:42 UTC by GI
Updated 2025-09-24 08:20:03 UTC by GI