← All Posts
DSA Series · Trees

Tree Algorithms & Patterns

This section covers the essential tree algorithms that appear in interviews, competitive programming, and real systems. Each algorithm has its own dedicated post with detailed explanations, code, and interactive animations.

The Algorithms

Complexity Summary

Operation BST (average) BST (worst) AVL / Balanced
SearchO(log n)O(n)O(log n)
InsertO(log n)O(n)O(log n)
DeleteO(log n)O(n)O(log n)
TraversalO(n)O(n)O(n)
HeightO(log n) expectedO(n)O(log n) guaranteed
LCAO(h)O(n)O(log n)
DiameterO(n)O(n)O(n)

Suggested Reading Order

  1. Height, learn the bottom-up recursion pattern
  2. LCA, BST ordering + general DFS split
  3. Diameter, builds directly on height
  4. Serialization, practical encoding/decoding
  5. Interview Patterns, tie it all together with templates