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.
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.
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 ❤️🙌
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
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).
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
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?
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?
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.
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
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 :)
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 :)
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.
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??????
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 ?
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 ...
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.
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.
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
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?
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!
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
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 :)
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]
***** 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?
+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.
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 !
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?
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
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!