Cutting Rod dynamic programming

preview_player
Показать описание
Given a rod of length and prices at which different length of this rod can sell, how do you cut this rod to maximize profit
Рекомендации по теме
Комментарии
Автор

This dude is nostalgia. I still remember watching him when I was in the very lows of my life, struggling to even reverse an array and doubting myself whether I would make it into tech or not. Now after 2 yrs, I can proudly say that the impact his channel made in my self taught DSA journey is commendable. Thou many of this DP vids do not explain when for this subproblem we need the answer of this subproblem. but that's fine, since after I used to watch his solution I would go over it myself and try to figure out what happened in it. And maybe that's the reason of my sharpened DSA skills.

somaroy
Автор

Life saver! I spent 3 hours trying to make a good guess and failed. Then I took 5 minutes to figure it out by watching your video. Thank you sir!

hjkc
Автор

Thank you so much! You are helping me so much in my Algorithm's class with Rod-Cutting since my professor did a poor job in explaining it without going into detail. ♥

GuitarheroWWEduh
Автор

similar to knapsack I guess, rod length is the max capacity of knapsack and we've to maximize profit ie maximize items which we can put in the knapsack.

AKHILPOKLE
Автор

Tushar you really are an amazing teacher!

qwarlockz
Автор

The question is incomplete without the cost of rod-piece of length 5, i.e. if we do not cut the rod. That's the reason when it is feeded in the code, it produces result 10 instead of 12.

PrashantNigam
Автор

I really like this guys teaching.
I understand what dynamic programming is trying to do, but I do not get how to code it up

sonfuniverse
Автор

how about setting a manual camera focus instead of auto focus?

usmankhalid
Автор

For some reason I didn't understand any of this in class. Thanks sir.

cornmasterliao
Автор

thanks man.. it was a really great video.. plz upload more

karan_vishwakarma_
Автор

The explanation could have been more intuitive instead of saying "go here", "add this and that", "take max from this and that". Kindly remake the video explaining the concept in terms of array indices, the use of optimal substructure and overlapping subproblems. Appreciate your efforts though!

terigopula
Автор

This is pretty simple. Infact it is simply a different version of the 0/1 Knapsack Problem. Take the main length to be the weight of the bag and the weight of the difference smaller lengths as the weights of the different items and the prices and the values of the corresponding items.

aradhyeagarwal
Автор

I don't quite understand why you do "two steps back" at around 6:00 - could you explain this in a bit more detail?

airex
Автор

Could you upload the video with stating reasons behind e.g. when you are at rod length 3(col) and cutting it into the length of 2( row 2) why are you going back to 2, 1 and then adding the rate of length of rod 2?

We can understand algorithm by looking at the code but the explanation should be of these small things about why we are doing that?

_Nikhil_Bagde_
Автор

Hi thanks for the instruction. However, I'm having a question:
When you go back to find the actual answer after filling the table. How would you consider all the possibilities that will make it to the length of 5, ? for example: in the video at length 5 and profit 12 you can cut 2, 3 OR 1, 2, 2, both will give you 12.

dustinv
Автор

The github algorithm function recursiveMaxValue does not work with the input used in the video. I used the array 2, 5, 7, 8 and 4 as input. It gives the result 10 instead of 12 as per the video.

vijendert
Автор

thanks a lot Tushar but on each DP solution you should explain subproblems

prodev
Автор

Thanks a lot for your time and efforts

true_human_
Автор

thnx tushar for the great work... keep posting

aalsicoder
Автор

Very nice tutorial. Crystal Clear explanation!

Do you have any tips on how to 'word' the subproblems? In all your videos, the wording of the subproblems seems to be a very critical thing.

bolestah