A binary tree is a tree where each node has at most two children (left and right). A Binary Search Tree (BST) adds ordering: left child < parent < right child, enabling O(log n) search, insertion, and deletion. Self-balancing BSTs (AVL, Red-Black) maintain O(log n) guarantees.

How Binary Tree Works

BST lookup: search for 7. Start at root (10). 7 < 10, go left (5). 7 > 5, go right (7). Found! Each comparison eliminates half the tree. Balanced trees guarantee O(log n); unbalanced trees degrade to O(n) — a linked list in the worst case.

Key Concepts

  • BST Property — Left subtree values < node < right subtree values — enables binary search on tree structure
  • Traversals — In-order (sorted output), pre-order (copy tree), post-order (delete tree), level-order (BFS)
  • Balanced Trees — AVL and Red-Black trees self-balance after insertions/deletions — guarantee O(log n) height
  • Heap — A complete binary tree where parent ≥ children (max-heap) — used in priority queues and heapsort

Learn Binary Tree — Top Videos

Binary Tree Educators

Frequently Asked Questions

When are binary trees used in practice?

Database indexes (B-trees), in-memory sorted data, priority queues (heaps), expression parsing, Huffman encoding, and many interview problems.