classnotes RTX 4070 Ti SUPER · faster-whisper · DeepSeek

5101 - Design & Analysis of Algo

← 5101 - Design & Analysis of Algo

DAA_27 Sep

Date 2026-09-27 Length 1h 20m Words 10,289 Segments 771
⤓ Download transcript (.txt with timestamps) ⤓ Plain transcript (.txt) ⤓ Transcript (.md)

Summary


session: "5101-design-analysis-of-algo/2026-09-27 0000 DAA 27 Sep"

title: "DAA 27 Sep"

date: "2026-09-27 00:00"

duration: "1h 19m"

language: "en"

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

parts: 2

transcript_chars: 51312

generated: "2026-11-23T23:47:36+05:30"


DAA 27 Sep

Overview

This class completes the maximum sub-array problem by moving from brute force and divide-and-conquer to dynamic programming, culminating in Kadane's algorithm and its index-tracking extension. It then introduces Strassen's matrix multiplication as a second divide-and-conquer case study, showing how reducing multiplications from 8 to 7 lowers complexity from n³ to n^2.81. The class also compares divide-and-conquer, DP and brute force, and discusses when each paradigm applies. It sits at the transition point in the course from classical divide-and-conquer recurrences to dynamic programming.

Learning outcomes

Core concepts

Maximum sub-array problem

A set of values stored in an array containing both negative and positive signs; we must identify a subset whose sum is maximum. It matters because it is the one problem for which brute force, divide and conquer and DP all exist simultaneously, making it the ideal comparison case. Special case: if there is one positive number and all others are negative, the positive number itself is the maximum sum (including any negative number would reduce it).

Brute force approach

Used a heuristic to minimize the search space — removing reoccurrence of elements / duplicate entities — reaching computational complexity of order n square. It is the fallback when neither divide and conquer nor DP applies.

Divide and conquer approach

Divides the subarray into smaller components until a single element is reached (base condition of the recurrence). Then identifies left sum, right sum and cross sum. The subarray can lie in the left sub-half, the right sub-half, or on the intersection. It is top-down: split the big problem into smaller and smaller subproblems, solve, go ahead. Complexity n log n.

Base case

When high is equivalent to low (one number), return low, high and A of low.

Cross sum

From the median, go to one side and to the other side; take the maximum possible sum value on the left side and the maximum possible value on the right side; Ls + Rs gives the cross sum. Its cost is order n (from the median we go at most n by 2 on each side), which drives the overall n log n.

Dynamic programming (DP)

Primarily a bottom-up approach — solve smaller variants of problems, aggregate them to get the final result. At each stage it preserves/stores the outcome of the previous state, and at each step gets the best value possible. DP algorithms are faster but memory-inefficient because they store the result of all previous/optimized outcomes at each step. On the cost of memory we get a faster algorithm; since memory is now sufficiently large, DP is more viable in the current scenario.

Divide and conquer vs. DP

Divide and conquer: solve one half, store the result in temporary storage, shift to the other half, then aggregate upward; results of a solved part are discarded once aggregated ("these results are gone"). DP: solve all sub-parts at a level simultaneously (e.g., O1, O2, O3, O4, then O5, O6, then upward), storing all outputs at each level; among these, the best case is propagated upward. DP stores previous results, which creates memory usage; divide and conquer need not store results because a solution is obtained at each step. Faster: divide and conquer is n log n, DP is n.

Kadane's algorithm

The DP variant for solving the maximum subarray problem; imposes only order n computational complexity (a single for loop running n − 1 times). Kadane's moves from one index to the next, solving subproblems incrementally: for the first two indices the max value is 1, for the first three it is 1, for the first four it is 4, and so on. Each step reuses the previously stored result, which is why it is described as working like dynamic programming from a different angle. The hierarchical (tree-like) arrangement is only possible in tree-like problems; here the max sum is obtained iteratively, step by step.

Recovering the subarray

Kadane's algorithm as stated gives only the maximum sum value, not the indices. To get the subarray, additional steps must be added: whenever there is a change in the value of the max sum, store that index (e.g., in an additional array); the two stored indices are treated as the start and end of the subarray. This is an "assumptive" extension, not part of standard Kadane's — any mechanism you devise is acceptable ("whatever logic you write that is up to you"). Example approach: maintain an index array and an output array simultaneously (e.g., indices 1, 2, 3, 4 with outputs 1, 1, 4, 4); after evaluating the sum 6, check where 6 first appeared (e.g., index 6) and go back to where the increment started (4).

Strassen's algorithm

Given by the mathematician Strassen. Instead of 8 products for a 2×2 multiplication, it performs the operation in 7 products by increasing the number of additions and subtractions. It is a divide-and-conquer algorithm: any large matrix is ultimately brought down to 2×2. The seven steps were given by Strassen (hence the name); the derivation/proof can be looked up in Cormen.

Square-matrix requirement

In Strassen's multiplication the matrices must be square and of order 2, 4, 8, 16, 32, 64, and so on. This is mandatory. A 4×4 matrix is treated as 2×2 blocks of 2×2 matrices; a 16×16 is reduced to 8×8, then 4×4, then 2×2, at which point the 7-step procedure is applied.

Choosing a paradigm

Dynamic programming cannot be applied everywhere, nor can divide and conquer. If a problem can be broken into subproblems and a recurrence/recursive variant can be formed, divide and conquer or DP may apply. If storing previous results helps make the next decision, DP applies; if storing results is not possible or not fruitful, DP does not apply. If neither applies, use brute force. Example: for the closest pair problem, DP cannot be applied, so divide and conquer is used.

Formulas and maths

Worked examples

Divide-and-conquer example

Array: 13, −3, −25, 20, −3, 16, −23, 18 with indices 1, 2, 3, 4, 5, 6, 7, 8 (a bigger problem of 16 elements was mentioned; students may instead take a 5–6 element sub-array).

Kadane's example

Array: −2, 1, −3, 4, −1, 2, 1, 1, −5, 4:

Partial re-explanation with index tracking

Array −2, 1, −3, 4, −1, 2, 1, only up to index 7:

Kadane's index-storing illustration

At i = 2, 3, 4, 5 the value is not changing, so the stored index stays 2; when 4 is reached, the index becomes 4; when 6 is reached for the first time, that value is also stored — giving the two points where the value changed (4 and 6).

Strassen on a 2×2 example

A = [[1, 2], [3, 5]], B = [[3, 2], [1, 3]].

Direct multiplication (A · B):

Via Strassen:

Combining:

Result: [[5, 8], [14, 21]] — identical to direct multiplication. The number of computations appears larger, but the dominating operation (multiplication) is reduced to only 7.

Questions asked in class

Transcript

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

loading…