Data Structures & Algorithms chapters
  1. 01Asymptotic Analysis & Complexity
  2. 02Arrays & Strings Algorithms
  3. 03Searching & Sorting Algorithms
  4. 04Linked Lists
  5. 05Stacks & Queues
  6. 06Recursion & Backtracking
  7. 07Binary Trees & BST
  8. 08Heaps & Priority Queues
  9. 09Hashing & Hash Tables
  10. 10Graphs & Graph Algorithms
  11. 11Dynamic Programming (DP)
  12. 12Greedy Algorithms & Bit Manipulation

Chapter 7

Binary Trees & BST

4 topics in 3 parts

Key ideas

Input Size (n) → Time (T) ↑ O(1) O(log n) O(n) O(n log n) O(n²) O(2ⁿ)
Binary Trees & BST
ApproachTime ComplexityAuxiliary SpaceKey Limitation
Brute Force ApproachO(N²) or O(2ᴺ)O(1) / MinimalTimes out on large constraints ($N > 10^4$)
Optimal ApproachO(N) or O(N log N)O(1) / O(N)Requires sorted invariant or hash set lookup
Theoretical Lower BoundΩ(N)O(1)Must inspect every element at least once

All 4 topics in Binary Trees & BST

  1. Trees

    • Binary Tree Terminology
    • Tree Traversals (DFS vs BFS)
  2. BST

    • BST Search, Insert & Delete
  3. Trees

    • Lowest Common Ancestor (LCA)