34 Matrix Chain Multiplication Recursive

preview_player
Показать описание
Matrix Chain Multiplication using Recursion
Given a sequence of matrices, find the most efficient way to multiply these matrices together. The problem is not actually to perform the multiplications, but merely to decide in which order to perform the multiplications.

------------------------------------------------------------------------------------------
Here are some of the gears that I use almost everyday:

PS: While having good gears help you perform efficiently, don’t get under the impression that they will make you successful without any hard work.
Рекомендации по теме
Комментарии
Автор

(1)= Intro
(2)= knapsack Intro
(3-12)= 0-1knapsack
(13-17)= Unbounded knapsack
(18-25)= Longest Common Subsequence types
(26-32)= Longest Palindromic Subsequence types [part of LCS]
(33-45)= Matrix Chain Multiplication
(46-50)=Binary Tree regarding DP

biswajitsahoo
Автор

Despite of the hold on concept what makes this channel standing out to others is the energy level and enthusiasm of bhaiya unlike most of other youtube channels where they all sound sleepy or dead. Thanks alot

mradulagrawal
Автор

Correction:
07:22
The value is actually 27, 000. So making (ab)c the smaller and preferable choice at 4500. Everything else is same, just the choice will be different...
Thanks

sujankumarpatro
Автор

Thank you so much ...this DP series is helping me a lot 😊

udaykumar-iuok
Автор

33 of 50 (66%) done! A long video, but was worth it to understand the range of k. I have seen many versions, some using gradually incr len of sliding window, etc., but this one is more clear. I use terms lo and hi instead of i and j for easy readability.

anant
Автор

These lecture series are like The New Testament of Dynamic Programming. It is going to serve the generations to come. Great work and huge thanks.

pallavirawat
Автор

At i == j the cost is zero not because there's only one element in the array. It'll be because there's no other matrix to which the remaining matrix will be multiplied

Ex. [10, 20]

Here i = 1, and j = 1. So, there's only one matrix in the array and no other matrix to which this matrix can be multiplied. So, there will be no multiplication, hence the cost of multiplication becomes zero

rishabsharma
Автор

Trust me, this is the *best* matrix chain multiplication dp explanation on the whole internet.
Can u pls tell where did u learn it from? I just wanted to know whether u learnt from books or some teacher.
Thanks again!

parthsalat
Автор

Your series is the benchmark in explaining dp concept. No one on earth explained it better.

MegaSethi
Автор

recursion is seriously a magic we are not telling it to multiply a[i-1]*a[i] and it is doing that by itself seriously I am amazed to see recursion!

lakshyamehta
Автор

Thanks Aditya again. Putting in some simple term that I understood. Taking an example we want to multiple : A*B*C*D*E
Here K is nothing but a pointer that decided the group split. Imagine that as a pointer in above example and try to split in two groups.
So first we split the whole thing in groups, and again in small group and so on until we get single valid input, then return that value . Return answer and keep taking smallest from each split.
Ex :
Group 1. : A*B
Group 2 : C*D*E

so solution will be : Cost of Group_1 + Cost of Group_2 + Cost of Group1 *Group2 .

We all know that for matrix multiplication : (10*30 ) ( 30*40 ) => 10*30*40, which is row_group_1 * row_group_2 * column_group_2

in the recursion for loop, third term is something that will generate the value and return since it has the actual formula of the matrix multiplication of smallest valid input : so recursion(group1) + recursion(group_2) + row_group_1 * row_group_2 * column_group_2 .

Happy learning :)

gpatil
Автор

sir i beg you please cover more topics....It's beacause apke saath aisi frequency match ho gyi hai that i cannot even express please please please please...Its a humble request

MASTERTBG
Автор

Coding Ninja is showing their add on this video.
Lol, as if I will buy any course after experiencing how Aditya teach.

Arjun
Автор

On 33 out of 50. Best playlist of DP, best than all free and paid resources available for DP

abhisheksingh
Автор

Sir, you're a LEGEND ! Thank you for helping us .

prernacore
Автор

For the first time in my life iam watching all the adds that coming in between videos just to support gem of Dynamic programing.❤️
Just remember his name Aditya verma ❤️....No more words

mrsukki
Автор

Bhai video dekhne ke baad, I had the 'aha' moment.. Literally how you connect the dots at the end and generalise the concept - you're the best... I'm sharing this with all my friends

There are so many questions on leetcode that uses this model - burst balloons, minimum cost to merge stones... Aapne toh saare banva diye, jisme pehle kaafi time waste kiya hai maine...

Thank you so much for this series

royarijit
Автор

dude your explanation cleaned up my room of dp and now everything is aligned perfectly, before this video i knew MCM, but it was plastic, now its concrete.

muditkhanna
Автор

@7:23 the value should be 27, 000 instead of 2700 I suppose.

vasubansal
Автор

this channel deserved at least 1M subscriber.

bharatkumavat