Really great explained! Enjoyed "the voice from above"
@konstantinrebrov675 Жыл бұрын
Wow, it's a very unique insight for dynamic programming, that it's actually originally a recursive problem that can be represented as recursion tree. And then we optimize it.
@bablobko4 жыл бұрын
Thanks a lot for the video. Great help to all of us. Please carry on. We are indebted.
@janpoonthong5 ай бұрын
I like the tree visualization, super helpful
@brianheartwood20712 ай бұрын
I lolled at the voice. thanks man this was informative and great.
@bertrandpinet57823 жыл бұрын
Awesome ! You are so much talented at teaching, thank you and please keep going =)
@ashishmore55494 ай бұрын
Thank you Sir Great Explanation
@David-zv5kw3 жыл бұрын
Thank you Sir! Very helpful!
@Anthony-cu3ot2 жыл бұрын
Hi, first awesome video ! Secondly, I haven't quite understood why you are calling RodCutting(length-i, Price) and not RodCutting(length-i, Price, Table) at 6:47. Am I missing something ? Thanks for your awesome work tho
@AlgorithmswithAttitude Жыл бұрын
That is a cut-and-paste error. It should have Table.
@omarmohamed34732 жыл бұрын
perfect explaination
@balaeinstein87104 жыл бұрын
thanks a lot sir. you are back again
@AlgorithmswithAttitude4 жыл бұрын
I actually posted this video a couple of months ago, but last week someone pointed out that there was an error on one of the later slides. It seemed serious enough for me to fix it and repost it.
@gabrielalvarez44914 жыл бұрын
Which package are you using to display pseudocode (the one shown in 06:46). Lately, I've been using the "algorithmic" package which I've found really useful because it highlights some usual keywords such as "for ... to", "while", "return" "if" "else" "loop ... until". Did you know that package? If so what were the reasons that made you not to use it? Thanks for sharing knowledge in such an organized and entertaining way.
@AlgorithmswithAttitude4 жыл бұрын
I'm just tabbing, maybe I'll check that package out in the future.
@DrMerlin62 Жыл бұрын
In the iterative solution why do we set tmp = Price[i] + Table[length - i]? Why not tmp = Table[i] + Table[length - i] instead? I don’t understand why we fix the value of the first cut instead of looking up the maximum value for that first cut from our lookup table. Isn’t Price[i]
@AlgorithmswithAttitude Жыл бұрын
There are multiple ways to find the correct answer. Your formula will also find it. After finding the optimal amount , if you then want to reconstruct what the best cuts are, it is slightly more direct to know what the first cut is, and take that piece whole, rather than making a cut and then recursively having to cut each of those two parts...but if you start from small i values, and keep the first i value that you find in case of ties, it should be that you end up finding an I such that price[i] == table[i], so it makes no real difference.
@DrMerlin62 Жыл бұрын
@@AlgorithmswithAttitude thank you for the explanation! Loved the video!
@wrenmoniker61372 жыл бұрын
I'm a little confused as to why at 5:43 the cost from 5 to the answer node is 14 even though the table says it's worth 12 dollars. Same with node 4 with a cost of 10, but it says 11. Is this a typo or am I missing a calculation?
@AlgorithmswithAttitude2 жыл бұрын
The table has the prices for a single rod. So, the store sells a length 5 rod for 12, and they sell a length 4 rod for 10. The algorithm is calculating how much you can get for that same length rod, if you are willing to cut it. For the length 4 rod, you can sell a length 3 rod for 9 and a length 1 rod for 2, for 11 total. For the length 5 rod, you can sell a length 3 rod (9) and a length 2 rod (5) for 14 total. The algorithm is calculating those numbers, given the numbers in the table.
@rajeshranjan14063 жыл бұрын
price must be price[i-1] instead of price[i] at 5:57
@davidtaylor28093 жыл бұрын
I think it is fine as is, I assume that the array has the sale price for length i at index i. I could have simplified the base case by starting max at 0, and getting rid of the first conditional, but usually only worry about clean up like that for the final version.
@infodemicyar87124 жыл бұрын
You're great!
@RafaelNascimento-qo1jp2 жыл бұрын
recursion is scary, it seems like a kind of sorcery hahaha
@AlgorithmswithAttitude2 жыл бұрын
Once you get it, it is really a powerful tool to approach a lot of different problems. But, wrapping your head around it is difficult to start. Which is why they say...if you want to understand recursion, first understand recursion.
@ThuyNguyen-ss7ed3 жыл бұрын
i want to code. Do you have ?
@AlgorithmswithAttitude3 жыл бұрын
Are you asking me for my code? Because that isn't the same thing as you coding if you want to code. And...my code for what? The rod cutting algorithm?
@Kirbychu1 Жыл бұрын
nice
@Rockyzach88 Жыл бұрын
Good
@bablobko4 жыл бұрын
In the bottom up solution given at the time 8:31, you are making a recursive call, that we can avoid altogether. RodCutting(int n, int[] price[]){ { int[] table = new int[n + 1]; table[0] = 0; int tmp = 0; for(int length = 1; length
@AlgorithmswithAttitude4 жыл бұрын
I am not sure what recursive call you are talking about? Do you mean the table look-up? The bottom up version has no recursive call.