Back to the 2025 paper

Module 1: Introduction

20257m

Write a short note on:

Recursion tree method

Worked SolutionAI Assisted

Recursion Tree Method

Idea

Visualize recurrence as tree where node = subproblem cost, level = total cost of that recursion depth, sum over levels gives total. Complements Master Theorem and substitution; handles forms master cannot (e.g., n/log⁡nn/\log n, uneven splits).

General Form T(n)=aT(n/b)+f(n)T(n)=aT(n/b)+f(n)

  • Root cost f(n)f(n)
  • aa children cost f(n/b)f(n/b) each → level1 af(n/b)a f(n/b)
  • a2a^2 nodes cost f(n/b2)f(n/b^2) → level2 a2f(n/b2)a^2 f(n/b^2)
  • Depth log⁡bn\log_b n leaves, leaves count alog⁡bn=nlog⁡baa^{\log_b n}=n^{\log_b a} cost Θ(1)Θ(1) each → leaf level Θ(nlog⁡ba)Θ(n^{\log_b a}).
  • Total T(n)=∑i=0log⁡bn−1aif(n/bi)+Θ(nlog⁡ba)T(n)=\sum_{i=0}^{\log_b n-1} a^i f(n/b^i) + Θ(n^{\log_b a}).

Example T(n)=3T(n/4)+Θ(n2)T(n)=3T(n/4)+Θ(n^2)

Level0 cn2cn^2, Level1 3c(n/4)2=3cn2/163c(n/4)^2=3cn^2/16, Level2 9c(n/16)2=9cn2/2569c(n/16)^2=9cn^2/256 → geometric ratio 3/16<13/16<1 → sum dominated by root Θ(n2)Θ(n^2) → T(n)=Θ(n2)T(n)=Θ(n^2) (Case3).

Example T(n)=2T(n/2)+nT(n)=2T(n/2)+n

Tree: root nn, level1 2⋅n/2=n2·n/2=n, level2 4⋅n/4=n4·n/4=n → each level nn, depth log⁡n\log n → total nlog⁡n+Θ(n)=Θ(nlog⁡n)n\log n+Θ(n)=Θ(n\log n).

Steps

  1. Draw tree, label cost per node/level.
  2. Determine depth (until n=1n=1 or constant).
  3. Sum levels; identify geometric vs constant series.
  4. Verify via substitution (induction).

Advantages

  • Intuitive for guessing bound for substitution proof.
  • Handles non-uniform: T(n)=T(n/3)+T(2n/3)+O(n)T(n)=T(n/3)+T(2n/3)+O(n) → recursion tree shows still O(nlog⁡n)O(n\log n) worst but more complex.

Use: Guess T(n)T(n) then prove via substitution method for rigor.

Similar questions

Budget AppAndroid App

Pocketly on Android

Log daily food, travel, and hostel expenses instantly. Set monthly spending limits and see where your money goes without complex spreadsheets.