Перейти к содержимому

Overlapping Subproblems and Memoization: Matrix Chain from Exponential to O(n³) | DSA Course L75

The Modern SDE

0:00 / 0:00

Overlapping Subproblems and Memoization: Matrix Chain from Exponential to O(n³) | DSA Course L75

1 просмотр · 10 дн. назад
The Modern SDE
1,27 тыс. подписчиков
1 просмотр · 10 дн. назад
Lecture 75 of the Complete DSA Course in Java by Engineer X · Part 4: Dynamic Programming, Greedy and Amortized Analysis. In this lecture • Overlapping subproblems, the second ingredient of DP, and why divide and conquer lacks it • Why independent and overlapping subproblems are not a contradiction • Plain recursive matrix-chain: counting how often each subproblem is solved • Proof by substitution that the plain recursion takes Ω(2ⁿ) time • Memoization in general, and memoized matrix-chain in Java, traced on the table • Why memoized matrix-chain is O(n³): computing calls vs table hits, with measured call counts • Top-down vs bottom-up trade-offs: constant factors, access patterns, unneeded subproblems • Reconstructing solutions: why a choice table beats recomputing choices • Interview angle: the complete DP recipe Chapters 0:00 A billion calls, 210 subproblems 0:31 Overlapping subproblems 1:26 Plain recursion on matrix-chain 2:26 Proof: exponential time 3:26 Memoization 7:14 Top-down or bottom-up? 7:47 Rebuilding solutions cheaply 8:21 Interview angle 8:52 Recap and quiz 9:59 Up next Book reference: Introduction to Algorithms (Cormen, Leiserson, Rivest, Stein), 4th edition, Section 14.3. The explanations, examples and code in this lecture are original. #DSA #Algorithms #DataStructures #Java #CodingInterview #EngineerX #DynamicProgramming #Memoization #OverlappingSubproblems #MatrixChainMultiplication #Java #CLRS