algoritmauzmanı
Sign in
TREN
Subtopic 6.2

Binary Tree with an Array

7lessons37 min0done

A binary tree can be laid out in an array level by level. The node at index i has its left child at 2i+1, its right child at 2i+2 and its parent at (i-1)/2, so no pointers are needed.

Each operation is its own lesson: building the tree, insertion, the four traversals, and search and height. The next subtopic repeats the same operations in the same order with linked nodes.

Lesson 6.2.1 A tree in an array: child and parent indexes6 min