Recurrence Relation - 1

Duration: 27 min

This video lesson is available to enrolled students.

Enroll to watch — Coal India Management Trainee (CS) Recruitment 2026

AI summary & chapters

AI Summary

An AI-generated summary of this video lecture.

This lecture introduces the Recursion Tree Method for analyzing divide-and-conquer recurrence relations, using T(n) = 4T(n/2) + Θ(n²) as the central example. The instructor first identifies the number of subproblems (a = 4) and the problem size reduction factor (n/2), then constructs a tree level by level: root T(n), four children T(n/2), sixteen grandchildren T(n/4), and so on. At each level k, there are 4^k subproblems of size n/2^k, and the non-recursive work per level is 4^k · (n/2^k)² = n², which is constant across levels. The tree has log₂n + 1 levels because the base case n ≤ 1 is reached when n/2^k = 1, i.e., k = log₂n. Summing the constant n² work over all levels gives T(n) = O(n² log n). The lecture emphasizes the general pattern: count subproblems, track problem size, compute per-level cost, identify number of levels via logarithms, and sum. This corresponds to the critical case (case 2) of the Master Theorem where f(n) = Θ(n^(log_b a)).

Chapters

  1. 0:00 2:00 00:00-02:00

    The lecture opens with the heading '2. Recursion Tree Method' and poses the question: find the time complexity of T(n) = 1 if n ≤ 1, and 4T(n/2) + Θ(n²) if n > 1. The instructor writes T(m) at the top of a tree and draws four branches downward, beginning the recursion tree. Pink arrows annotate the recurrence to identify '# Subproblem' (the coefficient 4) and 'Problem Size' (n/2), establishing the two key parameters needed to build the tree.

  2. 2:00 5:00 02:00-05:00

    The instructor constructs the first levels of the recursion tree. The root is labeled T(n), and it branches into four children each labeled T(n/2). He continues expanding to show the second level with nodes T(n/4), illustrating that each node produces four subproblems of half the size. The annotations '# Sub Problem' and 'Problem Size' remain visible, reinforcing that a = 4 subproblems are generated at each step with size reduced by factor 2.

  3. 5:00 10:00 05:00-10:00

    The tree is expanded further to show the general pattern at depth k. The instructor writes T(n/2^k) for the leaf nodes at level k, showing that after k levels of recursion, each subproblem has size n/2^k. The visible nodes include T(n/2), T(n/4), and T(n/8) at successive levels, demonstrating the halving of problem size. The base case condition 'if n ≤ 1' is referenced to determine when the recursion stops, which occurs when n/2^k = 1.

  4. 10:00 15:00 10:00-15:00

    Green annotations appear on the left side of the board labeling the number of nodes at each level: 4^0 = 1 at the root, 4^1 = 4 at level one, and 4^2 = 16 at level two. The instructor explains that the number of subproblems multiplies by a = 4 at each level, while the problem size divides by b = 2. The general form for level k is established: there are a^k = 4^k subproblems, each of size n/b^k = n/2^k. This systematic labeling prepares for computing the total work at each level.

  5. 15:00 20:00 15:00-20:00

    The instructor calculates the total work at each level by multiplying the number of subproblems by the cost per subproblem. At level k, the work is 4^k · (n/2^k)² = 4^k · n²/4^k = n². This shows that the work per level is constant (n²) regardless of depth, because the increase in subproblem count exactly cancels the decrease in individual problem size. The instructor points to this cancellation as a key insight, and references the base case 'if n ≤ 1' to determine the total number of levels.

  6. 20:00 25:00 20:00-25:00

    The number of levels is determined by setting the subproblem size equal to 1: n/2^k = 1, which gives k = log₂n. The instructor writes 'log₂n = k' on the board, indicating that the tree has log₂n + 1 levels (from level 0 to level log₂n). The total work is then the sum of n² over all levels, which equals n² · (log₂n + 1). The instructor simplifies this to O(n² log n), noting that the constant factor and lower-order terms are absorbed in Big-O notation.

  7. 25:00 26:43 25:00-26:43

    The final derivation is summarized on the board. The recurrence T(n) = 4T(n/2) + n² is expanded, and the per-level cost is shown as 4^k · (n/2^k)² = n². The total is written as the sum of n² repeated log₂n times, yielding T(n) = n² + n²·log₂n = O(n² log n). The instructor emphasizes that this is the critical case where f(n) matches n^(log_b a), and the log factor arises from summing equal costs across all levels. The result O(n² log n) is the final answer to the original question.

The lecture systematically applies the Recursion Tree Method to T(n) = 4T(n/2) + Θ(n²). The method proceeds in five steps: (1) identify a = 4 subproblems and b = 2 size reduction from the recurrence; (2) build the tree level by level, with a^k = 4^k nodes at depth k; (3) compute the cost per level as a^k · f(n/b^k) = 4^k · (n/2^k)² = n², showing constant per-level work; (4) determine the number of levels by solving n/2^k = 1, giving k = log₂n; (5) sum the per-level costs over all levels to obtain T(n) = O(n² log n). The central insight is the cancellation between increasing subproblem count and decreasing individual size, which produces equal work at every level. This corresponds to the Master Theorem's case 2 (critical case) where f(n) = Θ(n^(log_b a)) with log₂4 = 2. The lecture emphasizes that the logarithmic factor in the final complexity comes from the number of levels, not from any single level's cost.

Loading lesson…