DSA DSA In Depth
0%
lesson recurrencesakra-bazziasymptotics

Beyond Master Theorem: Akra-Bazzi for Uneven Subproblems

7 min read Module 1.1: Asymptotic Analysis, Recurrences & Memory Hierarchy Updated Oct 23, 2026
📄 Cheat Sheet
The Akra-Bazzi Method: Solving Divide-and-Conquer Recurrences Beyond Master Theorem
Nitish Kumar The Akra-Bazzi Method: Solving Divide-and-Conquer Recurrences Beyond Master Theorem Watch on YouTube ↗

Complete derivation of the characteristic exponent p and the Akra-Bazzi integral formula for recurrences with unequal subproblem splits.

0:00 / --:--

The Akra-Bazzi Theorem & Characteristic Exponent $p$

Consider a general divide-and-conquer recurrence with $k$ recursive branches:

$$T(x) = g(x) + \sum_{i=1}^{k} a_i\, T\!\left(b_i x + h_i(x)\right) \quad \text{for } x \ge x_0$$

where $a_i > 0$ are positive weights, $b_i \in (0, 1)$ are contraction ratios, $g(x)$ satisfies a polynomial-growth regularity condition, and $|h_i(x)| = O(x / (\log x)^2)$ represents small rounding perturbations (such as $\lfloor n/3 \rfloor - n/3$ or $+1$ boundary elements). The Akra-Bazzi method proceeds in two steps:

  1. Step 1 (Solve for the Characteristic Exponent $p$): Because $\phi(p) = \sum_{i=1}^k a_i b_i^p$ is strictly decreasing and continuous with $\lim_{p \to -\infty} \phi(p) = +\infty$ and $\lim_{p \to +\infty} \phi(p) = 0$, theIntermediate Value Theorem guarantees a unique real root $p \in \mathbb{R}$ to the characteristic equation: $$\sum_{i=1}^{k} a_i b_i^p = 1$$
  2. Step 2 (Evaluate the Akra-Bazzi Integral): The exact asymptotic growth of $T(x)$ is given by: $$T(x) = \Theta\!\left(x^p \left(1 + \int_{1}^{x} \frac{g(u)}{u^{p+1}}\,du\right)\right)$$
Recurrence Relation Characteristic Equation $\sum a_i b_i^p = 1$ Exponent $p$ Integral $\int_1^x \frac{g(u)}{u^{p+1}} du$ Asymptotic Bound $T(x)$
$T(n) = T(n/3) + T(2n/3) + \Theta(n)$ $(1/3)^p + (2/3)^p = 1$ $p = 1$ $\int_1^x \frac{u}{u^2} du = \ln x$ $\Theta(n \log n)$
$T(n) = T(n/5) + T(7n/10) + \Theta(n)$ (BFPRT) $(0.2)^p + (0.7)^p = 1$ ($\sum b_i = 0.9 < 1$) $p \approx 0.8398 < 1$ $\int_1^x u^{-p} du = \frac{x^{1-p} - 1}{1 - p}$ $\Theta(n)$
$T(n) = T(n/5) + T(4n/5) + \Theta(n)$ $(0.2)^p + (0.8)^p = 1$ ($\sum b_i = 1.0$) $p = 1$ $\int_1^x u^{-1} du = \ln x$ $\Theta(n \log n)$
$T(n) = T(n/3) + T(3n/4) + \Theta(n)$ $(1/3)^p + (3/4)^p = 1$ ($\sum b_i = 13/12 > 1$) $p \approx 1.1531 > 1$ $\int_1^x u^{-p} du = O(1)$ $\Theta(n^{1.1531})$

Formal Specification: The Linear-Work Sum Rule ($\sum b_i$ vs $1$)

When each recursive call has coefficient $a_i = 1$ and the non-recursive work is linear $g(n) = \Theta(n)$ (as in Quicksort partitioning and BFPRT selection), we do not even need to solve for $p$ numerically to know whether $T(n)$ is linear, log-linear, or super-linear! Evaluating $\phi(1) = \sum_{i=1}^k b_i$ immediately reveals the regime:

  • Contracting Subproblem Sum ($\sum b_i < 1 \iff p < 1$): Total problem size shrinks at every level of the tree (e.g., BFPRT $1/5 + 7/10 = 9/10 < 1$). The integral yields $\Theta(x^{1-p})$, which multiplies by $x^p$ to give $T(n) = \Theta(n)$!
  • Measure-Preserving Split ($\sum b_i = 1 \iff p = 1$): Every complete level of the recursion tree sums to $n$ (e.g., $T(n/10) + T(9n/10) + n$). The integral $\int_1^x u^{-1}\,du = \ln x$ yields $T(n) = \Theta(n \log n)$!
  • Overlapping Subproblem Sum ($\sum b_i > 1 \iff p > 1$): Subproblems overlap and expand down the tree. The integral converges to a constant $O(1)$, yielding $T(n) = \Theta(n^p)$.

Visualizing Uneven Recursion Trees: Shortest vs Longest Root-to-Leaf Spine

In $T(n) = T(n/3) + T(2n/3) + c n$, the leftmost spine reaches size $1$ at depth $\log_3 n$, while the rightmost spine reaches size $1$ at depth $\log_{3/2} n$. Every complete level above $\log_3 n$ sums to exactly $c n$ work.

c·n c(n/3) c(2n/3) c(n/9) c(2n/9) c(2n/9) c(4n/9) → Level 0 Sum = c·n → Level 1 Sum = (1/3 + 2/3)cn = c·n → Level 2 Sum = (1/9+2/9+2/9+4/9)cn = c·n Shortest spine: d_min = log₃(n) (Ω(n log n)) Longest spine: d_max = log_{3/2}(n) (O(n log n))
flowchart LR A["Uneven Recurrence: Σ a_i T(b_i x + h_i(x)) + g(x)"] --> B["Solve Σ a_i b_i^p = 1 for unique p"] B --> C["Evaluate Integral I(x) = ∫_1^x g(u) / u^(p+1) du"] C --> D["Multiply: T(x) = Θ(x^p · (1 + I(x)))"]

Hardware Reality: Why BFPRT Groups of 5 Work ($0.2 + 0.7 = 0.9 < 1$) While Groups of 3 Fail ($1/3 + 2/3 = 1$)

In Blum, Floyd, Pratt, Rivest, and Tarjan's (1973) deterministic linear-time selection algorithm (Median-of-Medians), the array is partitioned into groups of size $g$. For $g = 5$, finding the median of medians takes $T(n/5)$ and the worst-case partition discards at least $3n/10$ elements, leaving $T(7n/10)$. Since $1/5 + 7/10 = 9/10 < 1$, Akra-Bazzi gives $p < 1$ and $T(n) = \Theta(n)$. If instead you choose groups of $g = 3$, finding the median of medians takes $T(n/3)$ and the partition leaves $T(2n/3)$. Now $1/3 + 2/3 = 1.0 \implies p = 1$, and Akra-Bazzi proves the runtime degrades from $\Theta(n)$ to $\Theta(n \log n)$!

Numerical Solver for the Characteristic Exponent $p$

When $a_i$ and $b_i$ do not admit a closed-form algebraic root for $\sum a_i b_i^p = 1$, binary search (or Newton-Raphson) over the strictly monotonic function $\phi(p) = \sum a_i b_i^p - 1$ converges to IEEE-754 double precision in 60 iterations.

// C++20: Computing the Akra-Bazzi Characteristic Exponent p via Monotonic Bisection
#include <cmath>
#include <span>
#include <utility>

struct RecurrenceTerm {
    double a; // Branch multiplier (a_i > 0)
    double b; // Contraction ratio (0 < b_i < 1)
};

// Solves Sum_{i} a_i * (b_i)^p = 1 to 1e-12 precision in O(k) time
double solveAkraBazziExponent(std::span<const RecurrenceTerm> terms) noexcept {
    auto phi = [&](double p) noexcept {
        double sum = 0.0;
        for (const auto& t : terms) {
            sum += t.a * std::pow(t.b, p);
        }
        return sum;
    };

    // Since 0 < b_i < 1 and a_i > 0, phi(p) is strictly decreasing in p.
    double lo = -64.0, hi = 64.0;
    for (int iter = 0; iter < 80; ++iter) {
        double mid = 0.5 * (lo + hi);
        if (phi(mid) > 1.0) {
            lo = mid; // Sum too large -> need larger p to shrink b_i^p
        } else {
            hi = mid;
        }
    }
    return 0.5 * (lo + hi);
}
Recursion Tree, Master Theorem & Akra-Bazzi Level-Work Visualizer
n^(log_b a) vs f(n)

Compare per-level work a^d · f(n/b^d) across Balanced Case 2 (Merge Sort), Leaf-Heavy Case 1 (Karatsuba/Strassen), and uneven Akra-Bazzi T(n) = T(n/3) + T(2n/3) + Θ(n).

Step 1 / 7
Custom Input:
Timeline

Invariant & State

Master Theorem Case 2: n^(log_b a) = n^(log_2 2) = n == Θ(f(n)). Work per level is invariant at c·n across log_2(n) levels.
d=0: 1 × c·n = c·n d=1: c·(n/2) d=1: c·(n/2) (∑=c·n) All log₂(n)+1 levels do exactly c·n work ⇒ Total = Θ(n log n)
Branching / Shrink
a = 2, b = 2
Work per Level d
2^d · c(n/2^d) = c·n
Total Work
Θ(n log n)
[Step 1] Balanced recursion tree: 2^d subproblems of size n/2^d sum to c·n at every depth d.

Failure Modes & Adversarial Pitfalls

  • Violating the Perturbation Bound $|h_i(x)| = O(x / (\log x)^2)$: Floor and ceiling operations ($\lfloor b_i x \rfloor$) introduce $|h_i(x)| \le 1$, which easily satisfies $O(x / (\log x)^2)$. However, if a recurrence has $T(n) = 2T(n/2 + n / \log n) + n$, the perturbation $h(n) = n / \log n$ is too large! In fact, that perturbation accumulates across $\log_2 n$ levels to inflate the leaf count by $e^2$, breaking the naive $p = 1$ bound if not bounded carefully.
  • Applying Akra-Bazzi to $T(n - 1)$ Chip-and-Conquer Recurrences: In $T(n) = T(n - 1) + n$, the contraction ratio is $b_1 = 1$, which violates the strict requirement $b_i \in (0, 1)$. Always solve subtract-and-conquer recurrences ($T(n - c)$) by unrolling into an arithmetic or geometric sum.
Check yourself Question 1 of 4
Concept Check Characteristic Exponent Equation in Akra-Bazzi recall

For a general divide-and-conquer recurrence `T(x) = g(x) + Σ_{i=1..k} a_i T(b_i x + h_i(x))` with `a_i > 0` and `0 < b_i < 1`, how is the characteristic exponent `p` defined?

⚡ Interactive Challenge · Staff Level

Algorithmic Design & Complexity Check

Analyze the invariant, asymptotic bound, and hardware behavior before selecting.

Consider `T(n) = T(⌊n/2⌋) + T(⌈3n/4⌉) + n`. Does Akra-Bazzi apply in presence of the floor/ceiling rounding, and what can we immediately deduce about `T(n)`?

Key Takeaways

The Akra-Bazzi theorem solves uneven divide-and-conquer recurrences T(x) = Σ a_i T(b_i x + h_i(x)) + g(x) where 0 < b_i < 1.
The characteristic exponent p is the unique real solution to Σ a_i (b_i)^p = 1, generalizing the Master Theorem's p = log_b(a).
For unit-weight recurrences with g(n) = Θ(n), T(n) is Θ(n) if Σ b_i < 1, Θ(n log n) if Σ b_i = 1, and Θ(n^p) if Σ b_i > 1.
Floor/ceiling rounding and small boundary offsets (+O(1)) are rigorously absorbed by the perturbation term |h_i(x)| = O(x / (log x)^2).
Was this lesson helpful? Spot an issue or have a suggestion? Let us know on GitHub.
Report an issue