dp[i][j]= max( dp[i-1][j], profit[i-1]+dp[i-1][*j*-wt[i-1] ) you specified W instead of j while including the element in final else statement.
@techdose4u4 жыл бұрын
Yea right. It should be j.
@amitkumargupta67224 жыл бұрын
@@techdose4u Its okay...concepts are more important than code..
@Nieobliczalny1000 Жыл бұрын
@@techdose4u What if j i wt[i-1] will be smaller than 0? Generally index out of bound?
@savostyanov Жыл бұрын
@@Nieobliczalny1000 We prevent this case in this line if (i == 0 or j == 0) dp[i][j] = 0
@JitendraSingh-qd7jk Жыл бұрын
Stop copying and pinning aditya verma's code Sakthim
@vend574 жыл бұрын
saw an algoexpert ad before the video. Am I buying that course after knowing that Techdose has covered 5 X more problems than Algoexpert ?
@dhananjaychoudhary78364 жыл бұрын
Thanks a lot man. This is my 4th attempt to understand knapsack DP and also the last one.
@techdose4u4 жыл бұрын
Nice :)
@Neonb882 жыл бұрын
Congrats! Never quit!
@MohamedSayed-wl5cj4 жыл бұрын
Best video on KZbin explains Knapsack problem with clear way,thanks
@techdose4u4 жыл бұрын
Welcome :)
@bhargavsai24493 жыл бұрын
within 2 or 3 yrs you will have millions of subscribers, great channel.
@techdose4u3 жыл бұрын
Thanks :)
@aryankumar877714 жыл бұрын
the sheer clarity of the explanation
@theghostwhowalk4 жыл бұрын
Never knew about heap Vs Stack memory thanks much for in-depth explanation!
@techdose4u4 жыл бұрын
Welcome :)
@ismail89733 жыл бұрын
Your intuition explanation is on another level
@34_harshdeepraghuwanshi984 жыл бұрын
Sir your explanation is too much above from paid courses and also in your video i never get a doubt or if i get then you always cleared doubt by yourself later in video thanks a alot sir for providing free quality education 🙏🙏👍👍👍👍👍
@techdose4u4 жыл бұрын
Welcome bro :)
@dionisorules2 жыл бұрын
Thanks for presenting this problem so orderly, going from the decision making tree, to the recursive approach to end up translating that into the tabular iterative approach. Now this is no more black magic for me, but step by step sound reasoning. Like others said your capacity to explain these complex solutions is just brilliant and far superior to paid courses.👏🏼👏🏼👏🏼
@mikekibet17863 жыл бұрын
Another masterful explanation. If I could subscribe twice, I would.
@techdose4u3 жыл бұрын
❤️
@vaibhavkumargautam2 жыл бұрын
This is the best explanation i ever came across..
@sorajkandari96033 жыл бұрын
How can u be so clear in every single word u say. awesome bro !!
@gowthamsankaran677 ай бұрын
Thank you so much for the explanation. I was struggling with converting recursive to iterative code. This helped me a lot.
@techdose4u7 ай бұрын
Nice :)
@prathamanand10373 жыл бұрын
this was a bomb video, better than everything I have ever seen
@techdose4u3 жыл бұрын
❤️
@mallikarjunareddy48483 жыл бұрын
Thanks for the explanation. It gives me an idea on how to come up with bottom up solution for dp problems . It would have been great if you had covered why we are considering items from right to left. I sat for couple of hours thinking about it and finally, I could understand the benefit of considering items from right to left over left to right
@niksgupta363 жыл бұрын
Can you mention those here? I think he sorted the profit array in increasing, hence working from right to left.
@pradnyamahadik55408 ай бұрын
Wow...really amazing explanation💯
@namanvijay35143 жыл бұрын
great series , following this one 👍
@techdose4u3 жыл бұрын
Great ❤️
@mahendrasuthar73543 жыл бұрын
amazing bhai kya samjhaate ho mjaa aa gya thanks a lot.
@ashvinimeshram52423 жыл бұрын
Your alll vedios are really nice.and it help me alot in my concept buliding thank u so much🙏🙏🙏🙏really good content
@techdose4u3 жыл бұрын
Welcome :)
@salilkumar65003 жыл бұрын
Your explanation is crisp,clear n short. Very helpful to me . Keep the good work going on man,
@sarvarjuraev13762 жыл бұрын
Thank you very much for the accurate explanation.
@dhanashreegodase44453 жыл бұрын
best video i have ever seeen..excellent..thanks alot
@techdose4u3 жыл бұрын
Welcome :)
@jayanthjj3 жыл бұрын
Thanks for this Great Video series!
@nknidhi3213 жыл бұрын
Thank you..🙏❤️
@techdose4u3 жыл бұрын
Welcome :)
@nimishkumar97794 жыл бұрын
Thanks a lot! The best explanation.
@techdose4u4 жыл бұрын
Welcome :)
@codingexception65023 жыл бұрын
Your explanation is really good.
@adim12123 жыл бұрын
You and Aditya Verma both have explained DP thoroughly and both have messed up at same concept i.e. Mistaken Bottom-Up as a Top-Down approach. Did both of you shared same notes or what???
@hiteshchopra91813 жыл бұрын
Bro I was literally finding the same in comments as I was also confused haha. But no doubt both of them teach very very good.
@debdattabiswas49022 жыл бұрын
excellent explaination.
@garimakumari43463 жыл бұрын
woow man really great..nice job
@techdose4u3 жыл бұрын
Thanks
@MadForCs164 жыл бұрын
Hello sir, I have one doubt, in this process we're actually moving from bottom to up ....like n=0, W=0. then why are we calling it *top-down* approach? It should be called *bottom-up*
@techdose4u4 жыл бұрын
You are right. I had made a community post regarding this. Wish you were there 😅 But yea, it's bottom up.
@大盗江南8 ай бұрын
amazing video, thank u
@samarasimhachalla35093 жыл бұрын
When deciding about which one to go ahead with Memoization or Tabulation methods. Try to identify the no.of values in the DP table or array that is required to solve the problem. If the number is very less compared to the total size, then go ahead with Memoization for better time complexity because in the Tabulation method it'll compute the whole table, then give you the output. And yeah, if the number of values that need to be computed in the table or array, is not very small when compared to the total size, then yeah go ahead with tabulation. Credits: GFG
@amansingh.h7163 жыл бұрын
THANKS SIR
@techdose4u3 жыл бұрын
Welcome
@ankitparashar87303 жыл бұрын
I have solved most of dp problem using recursion and memoization .i felt memoization dp is easier than tabalization . Should I learn tabalization dp ???
@venkatadokku91904 жыл бұрын
Nice share. Can you point some questions associated with this concept ? Appreciated.
@techdose4u4 жыл бұрын
Subset sum problem
@abhigyansharma91083 жыл бұрын
Love You Sir
@techdose4u3 жыл бұрын
Thanks 😊
@rangapavankumar794 жыл бұрын
How come 'w' in last line is it 'j' b'coz 'j' is capacity of bag?
@techdose4u4 жыл бұрын
It will be j because j is current capacity.
@Neonb882 жыл бұрын
Wait his handwriting on a computer is so pretty. That's just the first thing I noticed. Obviously it's a good tutorial video, too
@Cloud-5772 жыл бұрын
Thank you
@rishviks89874 жыл бұрын
Sir I'm good at memoisation but I don't have any idea about tabulation coz I nerver used it. Should one know both of them?
@techdose4u4 жыл бұрын
Better to know both.
@srikantsharma64304 жыл бұрын
Well explained!
@techdose4u4 жыл бұрын
Thanks
@naman_goyal4 жыл бұрын
Very nice
@techdose4u4 жыл бұрын
Thanks
@KhushiYadav-fo9ul Жыл бұрын
Please correct me if I am wrong , the memoization is a top- down approach and tabulation is a bottom up approach .....
@techdose4u Жыл бұрын
While it looks just the opposite but you are correct :)
@kuntipatidar51914 жыл бұрын
how your concepts are so strong?
@priyank9074 жыл бұрын
Patience and practice
@adityaojha27013 жыл бұрын
We start filling table from smaller value to greater value, so this become bottom up approch. Am I right??
@Rasheed218 ай бұрын
Not really. Tabulation/Iteration is Bottom-Up even if you interate in decreasing order. Recursivion+Memoization is Top-Down even if your recusion is in increasing order.
@heedererroger93244 жыл бұрын
your approach to get maximum value is direction which is from right to left. But your table structure is left-top to right bottom to find maximum value. It's confusing... am I misunderstanding?
@imukai2 жыл бұрын
I get that this method gives you the total profit at the end of the table -- but how do you determine which of the elements in the set were selected to arrive at that sum?
@smitkarwatkar03 Жыл бұрын
use a prev array which will store the indexes of each optimal step. at the end you would get all the elements in your optimal solution
@manoranjaniiit4 жыл бұрын
too good
@techdose4u4 жыл бұрын
Thanks :)
@santoshr42122 жыл бұрын
Friends, can someone explain in which case memoization will be useful because unlike Fibonacci I dont see a case where same value/computation can be repeated because in each case weight may be different
@biswajitghosh93154 жыл бұрын
Love you bro
@piyushkumar-wg8cv2 жыл бұрын
You have messed up the indexes.
@_SajjadHossainTalukder3 жыл бұрын
A bottom-up algorithm "starts from the beginning," while a recursive algorithm often "starts from the end and works backwards" . That's why recursive algorithm is known as top down . U wrongly interpreted this top down Approach. It may be Bottom-Up approach. Please Make it clear.
@andresdallarizza15266 ай бұрын
fucking legend lov u adore u
@techdose4u6 ай бұрын
:)
@tech_wizard93154 жыл бұрын
Please make a roadmap for fresher to crack google in 6months
@learnersparadise74923 жыл бұрын
You copy pasted content of Mr Aditya Verma in English, just...even his calling of bottom up as top down is copied man....do some original work please 🥺🥺
@tvrao1234 жыл бұрын
too lengthy explanation
@techdose4u4 жыл бұрын
It was basics so it went long.
@Dryicicles4 жыл бұрын
lmao then shut up and dont learn
@manishkumartyagi18154 жыл бұрын
Looks like copied from the videos of Aditya Verma :D , exactly same.......... hahahahahaha
@vigneshvicki70202 жыл бұрын
i almost gave up trying to understand DP in tabulation, but Finally I did understand, Thank you very much bro🥹