Try   HackMD

Binary Tree Study Guide

Tree Types

Binary trees come in several variations, each with unique properties:

  1. Complete Binary Tree (CBT): Every level is filled, except possibly the last, which is filled from left to right.
  2. Perfect Binary Tree (PBT): All interior nodes have two children, and all leaf nodes are at the same level.
  3. Full Binary Tree (FBT): Every node has either 0 or 2 children.
  4. Binary Search Tree (BST): For each node, all elements in the left subtree are less than the node, and all elements in the right subtree are greater.

Tree Traversal

Understanding different traversal methods is crucial for working with binary trees:

  1. Inorder Traversal: Left subtree, Root, Right subtree
  2. Preorder Traversal: Root, Left subtree, Right subtree
  3. Postorder Traversal: Left subtree, Right subtree, Root
  4. Level Order Traversal: Visit nodes level by level, from left to right

Tree Properties and Operations

This section covers various properties and operations on binary trees:

Tree Depth/Width

Tree Paths

Tree Structure Modification

Tree Construction

Tree Validation

Special Problems

This section covers unique problem types related to binary trees:

Lowest Common Ancestor

Tree View Problems

Serialization and Deserialization

Node Deletion

Tree and Linked List Combination

Problem Difficulty Legend

  • 🟩 Easy
  • 🟨 Medium
  • 🟧 Medium-Hard
  • 🟥 Hard
  • ⬛ Very Hard

Additional Resources