Exit Slides

Binary Tree Array Representation

overview

Summary

Store a binary tree using an array_representation. Use 0_based_indexing. The root_index is 0. For node i: 

  • left_child_index = 2*i + 1
  • right_child_index = 2*i + 2
  • parent_index = floor((i - 1)/2)

This works best for a complete_binary_tree, giving a compact, heap like layout. If nodes are missing, keep a null_placeholder to preserve positions. Index access is O(1). Common uses include heaps and priority queues.

← Prev Topic Slide 1 / 3 Next Topic: Tree Traversal →