Matrix Chain Multiplication using Dynamic Programming | A visutorial with table-filling visualized!

preview_player
Показать описание
The matrix chain multiplication problem is to find the minimum number of multiplications required to multiply a chain of matrices. The video explains the dynamic programming (DP) based approach to solve the problem. The iterative version of the code is discussed. Finally, the video ends with a running animation of how the DP table is filled in real-time, helping to build intuition and visualization.
CAPTIONS recommended.

If you liked the video, please show your support by liking it and subscribing to the channel. It will motivate this channel to make more of these.
Subscribe if you want to watch videos uploaded in the future.
Timestamps:
Channel intro: (00:00)
Introduction to the problem: (00:05)
What is a matrix chain?: (01:50)
Number of multiplications depends on order: (02:19)
Greedy strategy?: (04:13)
Starting to think of DP: (05:28)
Recurrence relations: (07:54)
Recursive bruteforce solution: (09:16)
Iterative bottom-up solution: (11:08)
An animated running example: (13:43)
Рекомендации по теме
Комментарии
Автор

Watched it thrice and realized its the most crystal clear explanation available on youtube! Just a suggestion: Include a small test case and tracing of that test case so as to validate the Recurrence relation.

lokendrabohra
Автор

Some problems from SPOJ based on this concept:

TheAlgorithmicEye
Автор

Didn't understand how you generalized at 6:00 - 6:36 that The last step whould have combined 2 subproducts (a prefix of the chain and the suffix). What if there's a case Such as: M = ABCD and if we multiply them as A(BC)D results in the minimum cost? How does that generalization apply here?

lokendrabohra