Binary Tree
0% completed
Introduction to array based binary trees
Let us look at a complete binary tree. We can see a pattern if we try to enumerate the nodes of a complete binary tree (assign each node an integer label starting from 0), starting from the root and going top to bottom, left to right.
Enumerating nodes of a complete binary tree
We can see that for any node with enumeration
n(so the root isn = 0):
- The left child = (2 * n) + 1
- The right child = (2 * n) + 2
Liking the course? Check our discounted plans to continue learning.