classnotes RTX 4070 Ti SUPER · faster-whisper · DeepSeek

5101 - Design & Analysis of Algo

← 5101 - Design & Analysis of Algo

DAA_04 Oct

Date 2026-10-04 Length 1h 36m Words 11,769 Segments 698
⤓ Download transcript (.txt with timestamps) ⤓ Plain transcript (.txt) ⤓ Transcript (.md)

Summary


session: "5101-design-analysis-of-algo/2026-10-04 0000 DAA 04 Oct"

title: "DAA 04 Oct"

date: "2026-10-04 00:00"

duration: "1h 36m"

language: "en"

model: "deepseek-ai/DeepSeek-V4.1-Flash-1017"

parts: 3

transcript_chars: 57732

generated: "2026-11-23T23:52:28+05:30"


DAA 04 Oct

Overview

This class covers how to derive recurrence relations from algorithms, the three methods for solving recurrences (substitution, recurrence tree/iteration, and the Master Theorem), and a brief introduction to trees. It builds directly on the divide-and-conquer algorithms already covered (merge sort, quick sort, binary search, Strassen's) and on the closest-pair problem recap. The Master Theorem is treated in depth: its form, its three cases, the regularity condition for Case 3, and the situations in which it cannot be applied. The class closes with tree-figure questions that are deferred to the next session.

Learning outcomes

Core concepts

Closest Pair Problem (recap)

Given a set of points, identify the pair closest to each other. Median is used for partitioning, and estimating the median requires sorting first; in 1D sorting is no issue, but in 2D the x-coordinate is preferred as the sort key. The problem can be solved iteratively or recursively via divide and conquer. This motivates the recurrence analysis that follows.

Recursion and recurrences

Recursion is "repeating itself, repeating itself, repeating itself." Divide-and-conquer algorithms (merge sort, quick sort, binary search) divide recursively until reaching the base case (in merge sort, one element). A recursion has two cases — base case (stopping criterion) and recursive case (the recursive call) — and, rarely, initial conditions that specify the function's value for small input sizes (e.g., an algorithm applies when n is 6 or above; before that a different function/initial value applies). Well-formed recursion means that after each recursive call the smaller problem tends toward the base condition; if this does not happen, the algorithm's convergence is broken. A recurrence relation (e.g., for merge sort, binary search, Strassen's) is a relation from which the exact complexity cannot be claimed directly; the solving methods below are used to estimate it. In complexity estimation we ignore corner/boundary cases — e.g., we assume the two halves of the array are always equal, though for odd n one part is one greater. A recurrence is written for n > 1 (the recursive step) with a separate statement for n = 1 (the base case); the recurrence relations given are the recursive step only, not the base condition. Illustration: take f(n) = n − 6; for values less than or equal to 6 this becomes 0, so when n > 7 a recurrence relation can be applied, for 0 < n < 7 some other case applies, and there is a base case that stops at n = 1. Such initial states occur rarely, in only a few problems. The base condition is the last condition, and algorithm complexity depends on how the recursive structure behaves.

Three methods for solving recurrences

Master Theorem

Form: T(n) = a·T(n/b) + f(n), given a ≥ 1 and b > 1 (if b is not greater than 1 there is no convergence). f(n) must be an asymptotically positive function.

Procedure: immediately compute n^(log_b a); say this gives n^x. Compare with f(n), say n^y. Three possibilities:

Case 3 extra condition: a·f(n/b) ≤ c·f(n) for larger n, with c < 1, must also hold.

Results:

Note on epsilon: in Case 2 the epsilon condition was stated as "epsilon should be greater than 1, not greater than 0" [as spoken; flagged below]; c < 1 applies to Case 3.

Interpretation of the cases (from Q&A): Case 1 (subtracting) targets the maximum possible value of f(n) — worst case; Case 3 (adding) targets the minimum possible value of n^(log_b a) — best case; the equality case in between is the average case. The Master Theorem primarily gives the order of computational complexity; if something is theta it is obviously also big-O and big-omega. Forget the three symbols for a moment; what matters is the order. If g(n) is greater than f(n), we are in the omega case; if g(n) is less than f(n), we are in the big-O case; if they are equivalent, we apply theta. The big-O, theta and big-omega notations are the same upper-bound / lower-bound / tight-bound notations learned earlier.

Case intuition: If the cost of solving the subproblem at each level increases by a certain factor (epsilon), we are in Case 3. If solving each step is nearly equal to f(n), we are in Case 2. If in each step it decreases by a certain factor, we are in Case 1.

Why c must be strictly between 0 and 1: c can be zero or negative in principle, but it should be between 0 and 1 and should not be zero. If it is negative, then n/b is not reducing the problem size (as in well-formed recursion), the recurrence relation will never converge, and the strict less-than / greater-than conditions will not hold.

Choice of c in Case 3: The instructor took c = 1 in the Case-3 example, but the condition is c < 1. If you take the boundary case 3.5/4, that is applicable; if c has to be taken as a greater value, the Master Theorem cannot be applied there.

Real-time relevance: For an algorithm of the form a T(n/b) + f(n) that calls itself recursively, the Master Theorem gives the computational complexity. Directly looking at a T(n/b) + f(n) we cannot see how the algorithm behaves in a real scenario unless we reduce it to something like n log n, n^2 or n^3. Real examples already stated: merge sort, binary search, and the Strassen expression. There may be real business use cases, but for most of them the instructor does not think so.

When the Master Theorem cannot be applied:

Why epsilon must be fixed: In the Master Theorem the assumption is that epsilon remains fixed throughout. For logarithmic terms the epsilon is not fixed because logarithmic behavior is different — whatever we put as n + x will not be fixed. For functions where estimating epsilon is "floated" (can change its behavior), we can never apply the theorem. This is a drawback of the Master Theorem.

Aim: The whole aim is to get n^(log_b a) as close as possible to f(n) — either add epsilon, subtract epsilon, or make them almost equivalent — so it falls into Case 1, 2 or 3.

Deriving a recurrence relation from an algorithm

First write the algorithm. Then check whether there is any recursive structure. If a recursive structure exists, identify the "hidden" recurrence relation, and then solve that recurrence relation using the Master Theorem. If a problem is divided into two subproblems of equal size, the recursive part is 2 T(n/2); the cost of merging is added as the non-recursive term (e.g., order n or n^2). In exams, if a recurrence relation is given that was not taught, it will be provided; but for a real-world problem where you are making the algorithm, you have to think about how your algorithm is behaving. If in your algorithm the same function is calling again and again and again, there is a chance that a recurrence relation holds; try to identify what type of recurrence relation it is — only then can you apply the Master Theorem and other techniques.

Mixed algorithms (recursive + iterative parts)

In the Master Theorem structure T(n) = 2T(n/2) + f(n), f(n) is for the non-recursive part and T(n/2) (the 2 T(n/2) term) is for the recursive part. The same structure holds for an algorithm that has both recursive portions and non-recursive (iteration) portions. If the non-recursive part is more time-consuming than the recursive part, it will dominate, as seen in the three cases of the Master Theorem. Structurally, find which is the dominating factor — the dominating part is the complexity.

Tree figure question

A last leaf in the figure has no sibling on the left or right. This was confirmed as correct: the tree may be the result of multiple deletions — earlier it had a sibling, but that sibling is now removed. Such a height can also occur without any right siblings. Trees will be restarted from the beginning in the next class.

Formulas and maths

Used to classify and solve a recurrence.

Used to solve a recurrence the Master Theorem cannot handle.

Worked examples

1. T(n) = 9T(n/3) + n: a = 9, b = 3, f(n) = n. n^(log_3 9) = n². Compare with f(n) = n: n^(2−ε) equates to n¹ → subtraction → Case 1 → complexity of order n².

2. T(n) = 3T(n/2) + n²: a = 3, b = 2, f(n) = n². n^(log_2 3) = n^1.58. Since f(n) = n², add epsilon (1.58 + ε) to equate → Case 3. Check a·f(n/b) ≤ c·f(n): 3·(n²/4) ≤ c·n²; with c = 1, 3/4 ≤ 1 holds. Complexity = theta(f(n)) = n².

3. f(n) = n, a = 3, b = 5: n^(log_5 3) ≈ n^0.68. Compare with n → addition → Case 3. Check: a·f(n/b) = 3n/5 ≤ c·n; with c = 1 it is of course true. Complexity = theta(n).

4. a = 2, b = 2: n^(log_2 2) = n¹, equal to f(n) = n → Case 2 → theta(n^(log_b a)·log n) = theta(n log n). This is the merge sort recurrence.

5. a = 2, b = 2, f(n) = 1 (theta of n is 1 [as spoken]): n^(log_2 2) = n; compare with n⁰ → subtraction → Case 1 → theta(n^(log_b a)) = big-O of n.

6. T(n) = 2T(n/2) + n log n (Master Theorem fails): a = 2, b = 2, f(n) = n log n; n^(log_b a) = n^(log_2 2) = n^1. If we add epsilon we would get n^(1 + x) because of the log n term, but the epsilon is not fixed — logarithmic behavior is different — so the Master Theorem cannot be applied. Checking Case 3's condition: `a f(n/b) = 2 · (n/2) log(n/2) = n log(n/

Transcript

One line per segment, [hh:mm:ss] timestamp first.

loading…