Bölüm 1.2 · Simülatör

Recurrence & Master Theorem Visualizer

← Bölüm 1.2

T(n) = a·T(n/b) + n^k

Recursion Tree

nodes per level · subproblem size · work on the level

Recurrence & Master Theorem

Explore recurrences of the form T(n) = aT(n/b) + f(n), compare recursion-tree levels, and classify the recurrence using the Master Theorem.

How to use

  • Set a (number of subproblems, a ≥ 1), b (shrink factor, b > 1), k (the non-recursive work is f(n) = nk) and an example input size n, then press Analyze Recurrence.
  • The left panel shows the critical exponent logba, the Master Theorem case and the predicted bound.
  • The recursion tree lists one row per level i: ai subproblems (small squares, at most 30 drawn; “…” means more), each of size n/bi, and the total work on that level ai·(n/bi)k. The bar compares level work with the heaviest level. At most 10 levels are drawn.

Master Theorem

Compare f(n) = nk with nlogba:

  • Case 1 (k < logba): recursive work dominates; level work grows towards the leaves; T(n) = Θ(nlogba).
  • Case 2 (k = logba): every level contributes the same work; T(n) = Θ(nk log n).
  • Case 3 (k > logba): the root dominates; level work shrinks towards the leaves; T(n) = Θ(nk). Case 3 needs the regularity condition a·f(n/b) ≤ c·f(n) for some c < 1; for f(n) = nk it always holds with c = a/bk.

Examples

Recurrencea, b, kBound
Binary search1, 2, 0Θ(log n)
Merge sort2, 2, 1Θ(n log n)
Karatsuba3, 2, 1Θ(n1.585)
Strassen7, 2, 2Θ(n2.807)