Skip to main content
PreparationZone Logo
PreparationZone
Back to Fundamentals

Fundamentals · Medium · Free

Draw a recursion tree for merge sort or Fibonacci — why it matters.

FresherFundamentalsData Structures & Algorithms
Model answer

Recursion tree

Draw calls as tree nodes—leaves count × work per call estimates complexity (e.g., merge sort levels × merge cost).

diagram
mergeSort(n)
 ├── n/2
 └── n/2   → log n levels, n work/level → O(n log n)
java
int naiveFib(int n) {
  if (n <= 1) return n;
  return naiveFib(n - 1) + naiveFib(n - 2); // tree ~ 2^n calls
}
Fibonacci naive tree is bushy—explains exponential time.