Тёмный

Matrix Chain Multiplication 

Tushar Roy - Coding Made Simple
Подписаться 245 тыс.
Просмотров 445 тыс.
50% 1

Опубликовано:

 

23 окт 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 257   
@jackinab0x600
@jackinab0x600 4 года назад
You know its funny, I watched this video 4 years back when I was in my undergraduate and im returning here today while im doing my Masters. Thank you
@shashanksagarjha2807
@shashanksagarjha2807 4 года назад
please check this playlist : ru-vid.com/group/PLeF0b8iqbx4mogykbd82-HY9Y1-JS9MDr
@growandlearndaily
@growandlearndaily 2 года назад
I Appeared in the Google Inida Interview, In that mail along with JD , they were suggesting to watch @Tushar Roy's video. Great Achievement bro.
@BackToBackSWE
@BackToBackSWE 5 лет назад
Awesome video, this really helped me back when I watched it.
@nikhilshrivastava3227
@nikhilshrivastava3227 4 года назад
When is your video coming on this problem? He is good but your way of teaching is better.
@shashanksagarjha2807
@shashanksagarjha2807 4 года назад
please check this playlist : ru-vid.com/group/PLeF0b8iqbx4mogykbd82-HY9Y1-JS9MDr
@HARIHaran-ks7wp
@HARIHaran-ks7wp 3 года назад
the man, the myth, the legend!
@aditipawde5894
@aditipawde5894 9 лет назад
Hello Tushar! Your videos are really very good! They explain exactly how to crack a problem. Just one suggestion, if you could mention complexities (time and space) of each problem giving reason behind it, it would be very useful! Thank for all the videos.
@ravinamore5157
@ravinamore5157 7 лет назад
Aditi Pawde you saw this video 1 year back??!!!! whyyyyy
@mysteriousbillionaire7349
@mysteriousbillionaire7349 7 лет назад
those glasses tell you why...
@pranaytanniru7764
@pranaytanniru7764 6 лет назад
Ravina More you replied to her message 1 year back. Why??
@10emoguy
@10emoguy 6 лет назад
ok
@srivatsakulkarni2580
@srivatsakulkarni2580 6 лет назад
@@pranaytanniru7764 you replied to her message 7 months back. Why??
@RahulLohra
@RahulLohra 9 лет назад
You are a Genius , explaining the concept in just 11 minutes . Thanks
@LUX1111111111111
@LUX1111111111111 9 лет назад
I love Indian people so much! They are so darn good at programming and English, envy envy .. I am from China :) smart Indians
@abhinavkanoria7627
@abhinavkanoria7627 8 лет назад
Ha-ha 谢谢你! By the way I'm helping a person in China learn English and in turn he helps me learn Chinese and Chinese culture :)
@abhinavkanoria7627
@abhinavkanoria7627 7 лет назад
I met a Chinese person on RU-vid and now he's with me in WhatsApp. Also, I'm Facebook friends with another person in south China and we met on a Game of thrones fan group. Also try the app 'Hello Pal' it lets you connect with native language speakers around the world.
@abhinavkanoria7627
@abhinavkanoria7627 7 лет назад
*on
@devbackhome
@devbackhome 7 лет назад
How do you guys communicate? Whats the common language?
@shima3610
@shima3610 4 года назад
I envy Chinese people so much because of their perseverance and hard working :)
@Farren246
@Farren246 8 лет назад
Love that recursive code at the end; how it all comes down to a function with only two lines inside it.
@M.x_mutua
@M.x_mutua 7 месяцев назад
watching this video 2024 and its the Best. this man did good job long time ago👏👏👏👏👏
@ramanboywss
@ramanboywss 6 лет назад
Saving my life on my homework assignment, this and the knapsack problem. Thank you so much!
@devonpowell3006
@devonpowell3006 7 лет назад
You're the only person/resource online that I've seen explain the backtracking well enough to understand. Great job, and thanks!
@shashanksagarjha2807
@shashanksagarjha2807 4 года назад
please check this playlist : ru-vid.com/group/PLeF0b8iqbx4mogykbd82-HY9Y1-JS9MDr
@sachinsagar1994
@sachinsagar1994 6 лет назад
Tum bhot badhiya kaam karta hai Maksood bhai.. Or koi tumko Thank You ni bolta.. Aaj mai tumko Thank you bolne ko aya.. Thankyou bhai.. **jaadu ki jhappi intensifies** tum mereko pass kara dia ❤️🙌
@mohitsingla325
@mohitsingla325 9 лет назад
Seriously good job! explaining the concepts so effectively in that short time...
@anil21040
@anil21040 3 года назад
Thank you Tushar. Your crystal clear explanations really make problems simpler
@balasahebdabhade3091
@balasahebdabhade3091 9 лет назад
Very clear cut and best explanation. Thanks for sharing !!!
@onyinyechichukwuma689
@onyinyechichukwuma689 5 лет назад
Beautifully taught! I have watched a bunch of similar videos, and this is the only one that I understood! Thanks Tushar!
@Snehilw
@Snehilw 9 лет назад
I have seen all your videos buddy & the code too, these are excellent videos, kudos to you to create them & to have shared them with everyone.
@Snehilw
@Snehilw 9 лет назад
Tushar..this is a very good initiative. Good luck to you! Kudos
@saras_arya
@saras_arya 9 лет назад
Great videos tushar. one little thing. Only if you could have told that [2, 3] is the size of the matrix it would have been easier. Great Explanantion anyways. Subscribed already
@malharjajoo7393
@malharjajoo7393 8 лет назад
+Saras Arya - Good point. I was wondering about that.
@tarachandprajapati7112
@tarachandprajapati7112 6 лет назад
m glad i saw this comment before watching the video
@dedust8648
@dedust8648 4 года назад
exactly
@parthsalat
@parthsalat 4 года назад
Thanks a lot man! I was looking out for an explanation
@MrDivad006
@MrDivad006 5 лет назад
Time complexity is O(n^3) because number of subproblems is O(n^2) and time per subproblem is O(n). You get the number of subproblems by asking yourself how many subproblems there are where 2 matrices are being multiplied (answer is n-1), then how many subproblems where 3 matrices are multiplied (n-2) and so on until n matrices (n-1 + n-2 + n-3 + n-4 + ... + 1 = O(n^2)). You get the time per subproblem by realizing that the largest subproblem (compute min cost for n matrices) has n possible solutions which you need to compute and then find the minimum of, if the largest subproblem takes O(n) then all other subproblems also take O(n).
@katchie2888
@katchie2888 8 лет назад
This is great thank you so much. I have an exam today and you cleared this right up for me.
@Seanwong03
@Seanwong03 3 года назад
Best explanation I have seen so far. Thank you.
@hot13399
@hot13399 8 лет назад
For someone doesn't understand why matrix multiplication result is p * q * r, you can look at this article:www.personal.kent.edu/~rmuhamma/Algorithms/MyAlgorithms/Dynamic/chainMatrixMult.htm
@damizht
@damizht 8 лет назад
Dear Tushar, great explanation, thank you! Just 1 question, cannot understand the T[i][j] formula you wrote in the end. Could you please elaborate on it a bit more?
@Animalianzz
@Animalianzz 8 лет назад
Hi! Can you explain how the formula that you have used in the end will cover all the cases for example will it consider the case T[1][2]+val[0].first*val[0].second*val[2].second for the cell number T[0][2]? As according to the formula for given value of 'i' you are varying 'k' but i can also vary?
@christina_pupul6314
@christina_pupul6314 6 лет назад
在智障边缘被挽救了。。终于理解了动态规划!谢谢小哥哥!
@raivathg3457
@raivathg3457 5 лет назад
Very nice and easy to understand videos
@ajanasathian8192
@ajanasathian8192 9 лет назад
+Tushar Roy , How the matrices are multiplied? I didn't get that. Here every matrices are 1x2. Please reply to me
@ab001atg
@ab001atg 7 лет назад
While calculating for l=4, why did we not include the case to multiply 1 and 2 first and then multiply the result with say 0 or 3?
@yiikai
@yiikai 6 лет назад
Thank You!!! So much better than my lecture notes
@sony87863
@sony87863 7 лет назад
Probably the one of the easiest way of teaching matrix chain :D
@zokna
@zokna 8 лет назад
The formulation you wrote at the end on the table doesn't make sense. You wrote "take the minimum of one number". I guess you wanted to say "take the minimum of the newly computed number and the pre-existing number at T[i][j]". Your code is correct though: T[i][j] = min(T[i][j], q) where q = T[i][k] + T[k][j] + A[i]*A[k]*A[j] and A is the input array.
@ravikhannawalia3107
@ravikhannawalia3107 7 лет назад
Nope, its the maximum for the different values of k where k>=i and k
@Itsjustfaiq
@Itsjustfaiq 7 лет назад
The savior of my semester
@nisaradappadathil6380
@nisaradappadathil6380 6 лет назад
in the final recursive equation you said minimu of(something), but there is only one thing inside the bracket. It atleast need 2 things to take a min right? in the equation you shld have put k from i to j
@Himanshu-vd1jm
@Himanshu-vd1jm 9 лет назад
it would be better if you use bright marker....like black or red...rather than this blue one...because at some places...it was difficult to view clearly. P.s your videos are awesome :)
@dakshisatbest
@dakshisatbest 8 лет назад
i understood the procedure but how is the code formed. i am not able to understand the code
@utkarshsaxena8034
@utkarshsaxena8034 7 лет назад
Never Give Up Never Give Up !!!
@vardaanbajaj3181
@vardaanbajaj3181 6 лет назад
it's simple math n-L+1 tells how many continuous groups of L are formed, i+L-1 tells about the last matrix in the current group of L matrices. The rest is self explanatory :)
@rubeenasultana1187
@rubeenasultana1187 5 лет назад
Very good teaching!!
@MrKishorebitta
@MrKishorebitta 8 лет назад
hi Tushar, Thanks for your video.I want to practice on white board. One question about your white board.What is size of your white board?
@tranxuanuc9509
@tranxuanuc9509 3 года назад
continue doing your thing please cause i see you teach so well
@barrypops7499
@barrypops7499 7 лет назад
Btw, the reason he keeps track of what is multiplied by what is because *k* = the way you multiplied the matrices. Usually the k you selected (the minimum) is put into a choice table next to the table of multiplications. He doesn't really do much with recording the way he multiplied the matrices in this video.
@akashgupta9217
@akashgupta9217 8 лет назад
Great Explanation... You made it a lot easier to understand .. Kudos
@zeroimpetuous
@zeroimpetuous 7 лет назад
In L=-3, you could also multiply 1,2 with 3 which would make the total options of 3 to choose the min cost from. Why did you skip that?
@SarvenderDahiya
@SarvenderDahiya 7 лет назад
No he did not, at 6:25 he did that. For L=3 , we have two choices , 0 to 2 and 1 to 3, each with two options.
@RUKSUDAPORN
@RUKSUDAPORN 7 лет назад
how to solve Let P be a set of balanced parenthesis strings and P is recursively defined as follows. 1. e is in P, where e is an empty string. 2. If alpha, beta are in P, then (alpha)beta is also in P. Prove that every nonempty balanced parenthesis string can be obtained via rule 2 from a unique alpha-beta pair. Hint: Mathematical induction but induct on what??????
@harshitagarwal5188
@harshitagarwal5188 8 лет назад
i was a little confused on how to display the odering of multiplication and ur git repo too doesn't have path back tracking implementation ,can u implement path backtracking on ur git repo ?
@mgzy89
@mgzy89 6 лет назад
Thank you Tushar, your videos are wonderful!
@nitinpaliwal9196
@nitinpaliwal9196 8 лет назад
thanx a lot !! you made it very easy to understand and implement
@allisonkuhl5355
@allisonkuhl5355 7 лет назад
I think I finally understand! Thanks for the explanation. :)
@imdadali5146
@imdadali5146 7 лет назад
sir!! you r best in dynamic programming..........
@anjugopinath8616
@anjugopinath8616 4 года назад
The example in the video uses a 4 by 4 matrix. But, the code in github uses a 5 by 5 matrix. And, I think the logic is different for both
@LeonYapKL
@LeonYapKL 4 года назад
I think there is lack of description of the problem, the pair of number is the dimension of the matrix.
@TheAshishk007
@TheAshishk007 7 лет назад
Great tutorial, Simplified to the core , Thanks :D
@ytstudy7007
@ytstudy7007 6 лет назад
Sir ek doubt h ye bataiye hm jo determinant solve krte h to hum usme row ar coloumn dono operation lga skte h yaa fir sirf row or column?
@RakeshKumar-yn3hh
@RakeshKumar-yn3hh 6 лет назад
what is the relation between i, j and k? How to select k?
@kamalbahadur007
@kamalbahadur007 9 лет назад
u nailed it man..... concept clear js b4 exam..
@ProudBharatiyaTV
@ProudBharatiyaTV 7 лет назад
This looks like you have crammed the formula and just create video... You should have explained how you thought about the solution rather than just debugging the problem ...
@gsriram7
@gsriram7 7 лет назад
Exactly!
@truthprevails899
@truthprevails899 5 лет назад
Tushar has done a great job here. If you need further explanation you can request or you can create an explanation video and can provide the link. However, you can refer MIT 6 006 lecture 22 by Prof. Erick and then see this video. You can understand better.
@charan775
@charan775 4 года назад
His content is different than the others. He provides the method to fill the table that's it. That's really helpful for many people. If you want deeper explanation you should refer other videos.
@TheAlgorithmicEye
@TheAlgorithmicEye 4 года назад
If anyone is looking for a more intuitive explanation, I made a 3b1b-styled video, also animating how the DP table is filled at the end ru-vid.com/video/%D0%B2%D0%B8%D0%B4%D0%B5%D0%BE-wkIUHguF7bs.html
@kurinchimalarn8555
@kurinchimalarn8555 8 лет назад
Hi Tushar! Very good explanation. Thanks. Between in the link with source code, I see only the optimal cost returned. Do you have a version where the extracting optimal sequence is captured?
@aronquemarr7434
@aronquemarr7434 4 года назад
Came here to find out how to determine the order of multiplication from the table. Thanks.
@lalitmeghwal75
@lalitmeghwal75 4 года назад
what is the cost? how are you getting the cost by multiplying those 3 digits? how did you think of filling the table in this manner after knowing the recursive solution? Just filling the table after knowing the solution, I think that's not coding made simple. I hope you see my comment!
@prem-qg1ep
@prem-qg1ep 7 лет назад
is matrix size mandatory , can't we take other sized matrix for ex- 2x3 or 2x4 etc....
@soumiksarkar6089
@soumiksarkar6089 6 лет назад
Hello Sir! Which did you refer to for algorithms ?
@cellardoor8943
@cellardoor8943 8 лет назад
greetings from Greece! I have fully understanded this.However,in some exercises they don't give you the actual size of each matrix,but a "size sequence" ...For example, we have matrices A1,A2,A3,A4,A5,A6 with size sequence (2,3,4,5,6,7)...and i cannot understand what that means..Please explain it to me.Btw,I'm not sure if "size sequence" is a valid translation haha
@cellardoor8943
@cellardoor8943 8 лет назад
i don't think so.If that was the case,we would need 1 more number.
@mohdarshulmansoori9200
@mohdarshulmansoori9200 6 лет назад
It means you have matrices of order 2x3, 3x4, 4x5, 5x6, 6x7.
@taruntrikha5262
@taruntrikha5262 8 лет назад
Awesome explanation.. now its so clear to me.. tnx.. Subscribed
@saurabhgoel8191
@saurabhgoel8191 6 лет назад
very good i understood it very easily thanks
@zdravkanedyalkova261
@zdravkanedyalkova261 8 лет назад
Hi and thank you for your clip. I have a question: does the minimum stay the same if i take the minimum of the first 3 matrices multiplication and just multiply by the last one as in this case or i have to take the minimum of all four without the dependance on that :)
@zdravkanedyalkova261
@zdravkanedyalkova261 8 лет назад
And thank you again :)
@amellperalta
@amellperalta 9 лет назад
Good job! Thanks for the help.
@thiagarajansaravanan
@thiagarajansaravanan 8 лет назад
Awesome Explanation!
@shubhamgoyal2622
@shubhamgoyal2622 8 лет назад
So easily explained!
@SAINIVEDH
@SAINIVEDH 5 лет назад
Recursive solution: product(A,1,3) product(A,i,j){ i == j ---> return 0; mini INT_MAX; for(k=i;k
@satyendrapandey5644
@satyendrapandey5644 5 лет назад
What about a recursive approach? Just find where the max col, row combination found and then divide the problem into left and right?
@ankitsharma8221
@ankitsharma8221 5 лет назад
Basic recursion should be avoided for overlapping problems. You should aim for top-down dynamic programming if you still want to use recursion.
@KountayDwivedi
@KountayDwivedi 5 лет назад
Awesome way to solve this problem rapidly, brother. Not recommended for beginners, though. :-}
@s1337m
@s1337m 8 лет назад
what's the runtime complexity? O(n^3)?
@abdulrahmanbinrabiah4780
@abdulrahmanbinrabiah4780 7 лет назад
yes, O(n^3)
@ethanwang8951
@ethanwang8951 9 лет назад
Hey Tusha, first thanks for cool video. You are assuming the chain is pre sorted in a unique order for multiplication. which could not be the case for [4X2][2X3][3X2][2X4]
@ethanwang8951
@ethanwang8951 9 лет назад
***** If in the example above, we call them the matrix 1, 2, 3, 4. In this case, when you consider the two matrix scenario, not only 1x2, 2x3, 3x4, but also it's possible that 4x1 as well. So if (4X1)X2X3 turn out to be the lowest cost, could it still be covered?
@abhayasharma7065
@abhayasharma7065 3 года назад
your video is still the best one out there! :)
@radhe8765
@radhe8765 3 года назад
Sir is looking like Younger brother of ravindra babu ravula
@ashisharyan2020
@ashisharyan2020 5 лет назад
it would be of great help if you explain the logic behind your solution.
@souravsinghtomar8573
@souravsinghtomar8573 4 года назад
this reminded me of the college lecture to pass the exam
@robealamalik7763
@robealamalik7763 8 лет назад
great explanation...thanks alot sir
@w180112
@w180112 8 лет назад
nice explanation, thanks a lot!
@kaioh1384
@kaioh1384 5 лет назад
nice explanation.
@Hassaan509
@Hassaan509 7 лет назад
why the cost multiplying a matrix by itself is 0 ?
@MatticusF1nch
@MatticusF1nch 9 лет назад
At 4:55 I don't understand why you multiply 2x3x4. Similarly, I don't understand why you multiply 2x6x4 at 5:19
@MatticusF1nch
@MatticusF1nch 9 лет назад
***** Thanks for the speedy response. I wasn't really aware of the sizes of resulting matrices and how they multiplied together.
@vigneshsaikrishnamallya5777
@vigneshsaikrishnamallya5777 8 лет назад
in the formula wat is val[i] val[j] val[k] first and second ??
@hemavathi-wp6zb
@hemavathi-wp6zb 6 лет назад
very good explanation
@malharjajoo7393
@malharjajoo7393 8 лет назад
Sir, the table you have made, can there be more than one entry in a single cell ?
@judeosbert
@judeosbert 8 лет назад
+malhar jajoo No,We compute different combinations and take the minimum of all those computations. The sole purpose of the table is to easily backtrack the best combinations for matrix multiplication.
@tariqsaeid9856
@tariqsaeid9856 8 лет назад
Ohhhh! Thanks man, You are a life Savior!
@nishhhaaa1
@nishhhaaa1 5 лет назад
The first 3 minutes was complete confusion. You should have atleast introduced by explaining what matrix multiplication is and how matrices can be multiplied. I like your videos, but the dearth of basic intro to problems has always been an issue. I had to go to another video, understand the concept and then come back to listen to the rest of your video. Kindly take this as a constructive suggestion ! Good job otherwise !
@ManishSharma-lm3wg
@ManishSharma-lm3wg 4 года назад
Yaeh i felt same
@andrewphilip8574
@andrewphilip8574 4 года назад
i mean its kinda obvious that if you are learning matrix chain multiplication, you must be having a certain idea about it's basics
@abinavch2632
@abinavch2632 4 года назад
Even I felt the same...
@GuhaJanakiraman
@GuhaJanakiraman 4 года назад
There is a lot of comment about Tushar’s video needing an intro. Not every video in every concept needs a long intro. If you need that for every video there are channels that provide that. You come to Tushar’s videos to get to the point. Who else explains CMM in 11 mins?
@andreaslukita9427
@andreaslukita9427 7 лет назад
need help, what is k in the formula? thank you
@andyyork6471
@andyyork6471 9 лет назад
Does your method replace the method that uses the "S-Table?" If so, your method is obviously more quick to do by hand, and easier to learn. Though, the coding/algorithm would still be the same :D
@andyyork6471
@andyyork6471 9 лет назад
My class book shows an M-table, which you do in the video and then an S-table that helps find the final product. If you want to improve your knowledge on this you may want to look that up. However, your method took me 5 minutes during an exam and the other method we were taught in class took nearly 15 minutes for others. Thank you for the reply!
@anujgupta3397
@anujgupta3397 7 лет назад
can someone pls tell that at 5.52 why haven't we multiplied (0,2) matrix with 1 matrix??
@kunwoomyung1033
@kunwoomyung1033 8 лет назад
This is the best explanation! thanks a lot
@rayzhang336
@rayzhang336 8 лет назад
very clear. Thank you!
@OauthC2ID
@OauthC2ID 8 лет назад
Thanks! I've forked your GitHub repo.
@piyushjain2618
@piyushjain2618 7 лет назад
What is 'k' in the formula?
@pallesaikrishna
@pallesaikrishna 9 лет назад
undoubtedly the clear explanation and thanks for tutorial :)
@ankitanandsingh6887
@ankitanandsingh6887 7 лет назад
can u upload the explanation of maximum length chain of pairs using dynamic programming?
@madhundle
@madhundle 8 лет назад
This helped so much. Thank you!
@hellschatt
@hellschatt 8 лет назад
Nice explanation! I'm happy that you gave up SimplePickup and that you're teaching computer science now :P
@hellschatt
@hellschatt 8 лет назад
+Tushar Roy There is a guy called Jesse on the youtube channel "SimplePickup" and you reminded me of him. That's why I made this joke :P
@nikitagupta2961
@nikitagupta2961 9 лет назад
u r far much better than my professors .. keep up the gud work..bless u
@nikhilsendidwana3635
@nikhilsendidwana3635 4 года назад
Arre sir aap toh hero ho
@aleksandrsolovyov5310
@aleksandrsolovyov5310 5 лет назад
thanks so much
@sahajsomani9193
@sahajsomani9193 5 лет назад
The video just solves the program with no mention of dynamic programming. Forget the code, it doesn't even bring in the concept.
@darogajee3286
@darogajee3286 7 лет назад
Do Full video on Theory of Computation According to sylllabus of IPU/Delh MCA..
Далее
4.3 Matrix Chain Multiplication - Dynamic Programming
23:00
Longest Common Subsequence
7:55
Просмотров 765 тыс.
МЭЙБИ БЭЙБИ - Hit Em Up (DISS)
02:48
Просмотров 123 тыс.
Matrix Chain Multiplication - Dynamic Programming
31:01
Why 7 is Weird - Numberphile
12:03
Просмотров 1,9 млн
Longest Increasing Subsequence
7:09
Просмотров 442 тыс.
2.9 Strassens Matrix Multiplication
23:40
Просмотров 1,1 млн
Gabriel's Horn Paradox - Numberphile
18:20
Просмотров 952 тыс.