CoursifyCoursify

Complexity Analysis of a Divide-and-Conquer Recurrence

Complexity Analysis of a Divide-and-Conquer Recurrence

Verified Sources
May 26, 2026

In the analysis of divide-and-conquer algorithms, we frequently encounter equations called recurrence relations []. These relations describe the running time of an algorithm in terms of its execution time on smaller inputs.

Consider the following recurrence relation:

T(n)=2T(n/4)+n2lognT(n) = 2T(n/4) + n^2 \log n

This equation characterizes an algorithm that divides a problem of size nn into 22 subproblems of size n/4n/4, solving them recursively, and combines the results in n2lognn^2 \log n non-recursive step time. To find the asymptotic complexity of this recurrence, we can visualize the execution flow using a recursion tree:

To solve this systematically, we can apply the Master Theorem [].

Footnotes

  1. Recurrence Relations - GeeksforGeeks - Complete guide on solving recurrence relations using recursion trees, substitution, and master methods.

  2. Master Theorem (Analysis of Algorithms) - Wikipedia - Comprehensive overview of the Master Theorem's history, cases, and mathematical formulations.

Master Theorem for Divide-and-Conquer Recurrences

The Master Theorem Framework

The standard Master Theorem is used to solve divide-and-conquer recurrences of the form T(n)=aT(n/b)+f(n)T(n) = aT(n/b) + f(n), where a1a \ge 1 is the number of subproblems, b>1b > 1 is the factor by which the subproblem size is reduced, and f(n)f(n) is the cost of the work done outside the recursive calls .

Footnotes

  1. Master Theorem (Analysis of Algorithms) - Wikipedia - Comprehensive overview of the Master Theorem's history, cases, and mathematical formulations.

Evaluating the Recurrence Step-by-Step

  1. 1
    Step 1

    | From the given recurrence relation T(n)=2T(n/4)+n2lognT(n) = 2T(n/4) + n^2 \log n, we identify the parameters: - a=2a = 2 (number of subproblems) - b=4b = 4 (subproblem size division factor) - f(n)=n2lognf(n) = n^2 \log n (non-recursive work) .

    Footnotes

    1. Recurrence Relations - GeeksforGeeks - Complete guide on solving recurrence relations using recursion trees, substitution, and master methods.

  2. 2
    Step 2

    | Next, we compute the critical exponent which determines the growth rate of the leaves in the recursion tree: logba=log42=0.5\log_b a = \log_4 2 = 0.5 This means the number of leaves grows at a rate of n0.5=nn^{0.5} = \sqrt{n} .

    Footnotes

    1. CLRS Solutions | Exercise 4.5-1 | Divide-and-Conquer - Detailed textbook solutions illustrating Case 3 Master Method application for quadratic polynomial overheads.

  3. 3
    Step 3

    | We compare the non-recursive term f(n)=n2lognf(n) = n^2 \log n with the leaf growth term nlogba=n0.5n^{\log_b a} = n^{0.5}: - f(n)=Ω(n0.5+ϵ)f(n) = \Omega(n^{0.5 + \epsilon}) for any ϵ1.5\epsilon \le 1.5. - This indicates that the non-recursive work at the root level dominates the overall work, pointing toward Case 3 of the Master Theorem .

    Footnotes

    1. Master Theorem (Analysis of Algorithms) - Wikipedia - Comprehensive overview of the Master Theorem's history, cases, and mathematical formulations.

  4. 4
    Step 4

    | For Case 3 to apply, we must satisfy the [regularity condition]{def="A mathematical constraint in Case 3 of the Master Theorem requiring af(n/b) <= cf(n) for some constant c < 1"} for some constant c<1c < 1 and all sufficiently large nn: af(n/b)cf(n)a f(n/b) \le c f(n) Substituting our parameters: 2((n4)2log(n4))cn2logn2 \left( \left(\frac{n}{4}\right)^2 \log\left(\frac{n}{4}\right) \right) \le c n^2 \log n 18n2(lognlog4)cn2logn\frac{1}{8} n^2 (\log n - \log 4) \le c n^2 \log n Choosing c=1/8=0.125<1c = 1/8 = 0.125 < 1 satisfies this condition for all n4n \ge 4 .

    Footnotes

    1. CLRS Solutions | Exercise 4.5-1 | Divide-and-Conquer - Detailed textbook solutions illustrating Case 3 Master Method application for quadratic polynomial overheads.

  5. 5
    Step 5

    | Since Case 3 is verified, the non-recursive work f(n)f(n) dominates the recurrence. Thus, the overall time complexity is: T(n)=Θ(f(n))=Θ(n2logn)T(n) = \Theta(f(n)) = \Theta(n^2 \log n) This matches option (iii) .

    Footnotes

    1. Master Theorem: Practice Problems and Solutions - University of Western Ontario - Academic problem set demonstrating the application of various Master Theorem cases to recurrence relations.

The Power of Dominance

Whenever the non-recursive cost f(n)f(n) is polynomially larger than the leaf cost nlogban^{\log_b a}, the root level does almost all the work. The work decreases geometrically as you go down the tree, meaning the total time complexity is simply determined by the root's cost, T(n)=Θ(f(n))T(n) = \Theta(f(n)) .

Footnotes

  1. Master Theorem: Practice Problems and Solutions - University of Western Ontario - Academic problem set demonstrating the application of various Master Theorem cases to recurrence relations.

Comparison of Leaf Cost vs. Non-Recursive Cost

Visualizing the divergence between leaf cost sqrt(n) and non-recursive cost n^2 log n

Mathematical Proofs and Alternative Methods

Knowledge Check

Question 1 of 3
Q1Single choice

What is the correct asymptotic complexity of the recurrence relation T(n)=2T(n/4)+n2lognT(n) = 2T(n/4) + n^2 \log n?

Explore Related Topics

1

The Minimum Number of Colors for a Graph with $n>3$ Vertices and 2 Edges

A graph with more than three vertices that contains exactly two edges always has chromatic number 22.

  • Because an edge exists, at least two colors are required: χ(G)2\chi(G)\ge 2.
  • With only two edges the graph is bipartite (either two disjoint K2K_2 or a P3P_3 plus isolated vertices), so two colors are sufficient: χ(G)2\chi(G)\le 2.
  • No triangle K3K_3 or odd cycle can appear, eliminating the need for three or more colors.
  • Isolated vertices are adjacent to none and can reuse any existing color, leaving the chromatic number unchanged.
  • Consequently χ(G)=2\chi(G)=2, making option (i) the correct answer.
2

Lexical Analysis and the Main Structure Used: Finite Automata

Lexical analysis relies on finite automata—typically deterministic finite automata (DFA)—to recognize token patterns defined by regular expressions.

  • Regular expressions for identifiers, numbers, etc., are converted to NFAs then to a DFA for fast scanning.
  • The DFA processes the source character by character, tracking a single current state and emitting a token at each accepting state.
  • Queues, stacks, and trees support other compiler phases (parsing, AST construction) but are not the primary model for token recognition.
  • Lexers output a stream of tokens that the parser consumes for syntax analysis.
3

Solving the Recurrence $T(n)=T(n-1)+n$ by Substitution Method

The course shows how to solve the decrease‑by‑one recurrence (T(n)=T(n-1)+n) (with (T(1)=1)) using the substitution method.

  • Repeatedly substitute (T(n-i)=T(n-i-1)+(n-i)) until reaching the base case, yielding (T(n)=T(1)+2+3+\dots+n).
  • The resulting sum is the triangular number (\frac{n(n+1)}{2}).
  • The dominant term (\frac{1}{2}n^{2}) gives a tight asymptotic bound (\Theta(n^{2})).
  • For recurrences of the form (T(n)=T(n-1)+f(n)), expanding to a summation quickly reveals the closed form.
Chat with Kiro