EasyVery High Frequency25 min
Binary Tree Fundamentals
Tree terminology, traversal orders (in/pre/post/level), and recursive thinking.
Binary tree = each node has at most 2 children. Master pre/in/post-order DFS and level-order BFS. Most tree problems are solved with recursion.
Binary Tree Fundamentals
Operation Complexities
Operation
Time
Note
Pre/In/Post-order traversal
O(n)
Visit every node once
Height calculation
O(n)
Post-order: 1 + max(leftH, rightH)
Search in BST
O(h)
O(log n) balanced, O(n) skewed
Insert in BST
O(h)
Find correct leaf position
Level-order (BFS)
O(n)
Queue-based, visits by level
Code
Tree Traversals
O(n)All three traversals have same O(n) time complexityStep-by-step1 / 11
Treelevel links
1. 1
Tree: 1 is root
Root=1, left subtree rooted at 2 (with children 4,5), right subtree rooted at 3.
More in Trees
Tree DFS (Depth-First Search)
Recursive and iterative DFS for path sums, diameter, max depth, and subtree problems.
Tree BFS (Level Order)
Use a queue to traverse level by level — solve right-side view, zigzag, and more.
Binary Search Tree
BST properties, insertion, deletion, validation, and in-order traversal patterns.