Hey very good explanation, I agree on the comment that direct tabulation approach is not very intuitive to normal human mind, we have to build up the solution starting from recursion and memoization. Just one small comment, the tabulation approach is not top-down but bottom-up. It is called bottom-up, because we start the solution from base case (initialize matrix using base case) and build the solution to the top (t[n][w] in this case).
Oh yeah. of course I am glad you pointed it out. I messed up, those two terms have always been confusing to me !! 😅However our solution is still correct af, I am glad names don't effect the way you do things !! Let's just call one Memoization and the other Tabulation to avoid confusion. What I did in this solution is Tabulation. Thanks for pointing is out tho !! Keep watching and share ✌️
@@TheAdityaVerma I'd suggest adding a video after the introduction of the playlist that explains the difference between top-down (memoization) and bottom-up (tabulation). You can mention it in that video that whenever you say "top-down" in the following videos, you actually mean "bottom-up" or "tabulation". It's important that no one learns a wrong thing. Other than that, your videos are very helpful. :)
The videos are good, but even a minor mistake in standard terms also may lead to failure no matter the explanation is very good. You ought to add a frame at the start of each video that wherever you refer top-down, it is actually bottom-up, else, people will start losing faith. My intention is not from any means to hurt you, but since, your explanation is good, you need to be full-proof.
@@TheAdityaVerma So the recursive solution was top-down approach as we started at the top and kept making recursive calls until we reached the base case and then started returning values while the tabulation one was bottom up as explained in the comments, right??
This is just to let you know that this is the first time when someone has explained me "how to code" with such clarity! I am really very amazed and motivated today because of this video playlist.
@@TheAdityaVerma bhaiya yahi to prblm hai market me itna competition hai ki share karte wakt dar lagta hai actually nahi kar pata hu baki likes or comment to milega
@@TheAdityaVerma Excellent Explaination. But in the GFG knapsack problem. The memoize solution is not accepting, while the top-down is accepted. There is a time limit exceeded error.
I am working in IT for the last 7 years I have tried many tutorials for data structure and algorithm but no one explained like you. I really appreciate your effort. Please make the videos topic-wise from basic it can be paid or free.
I also felt the same way, thank you so much for time and effort Aditya Bhai. As you said all the youtubers just explained the tabular method but no one taught the same u r teaching i.e converting recursion into tabular method. hats off for your explanation and ideas. Keep uploading such problems and videos I am loving it.
I tried learning this from hell lot of YT channels like Tushar, Jenny, Apna College, Anuj Bhaiya, even MIT Open Courseware. One word, all are trash and I could understand nothing from them! Only a true coder like you who actually works in a company and who has grinded so hard to achieve it can explain this with such clarity. Tysm brother! 💓
Why cant I double like? This deserves a thousand likes. You opened a whole perspective of DP for me. Using recursion first to explain and then coming to bottom up approach was a stroke of masterpiece. I've always wondered how to solve DP with tabulation but this DP series is a life saver.
In my 3rd year now, and till date I've tried to learn from so many different resources but nothing like these videos. A genuine thank you from the bottom of my heart for keeping shit real and free. Stay the same when you hit those subscriber milestones on YT because you will. And soon! ✌️💯
BROooo ....I dont know how to thank you ....I was really looking for this exact way of teaching ... and yesterday only my senior suggested me from IIT Guwahati to follow you ...and i wasn't able to sleep after seeing the way and quality of content you have provided ....i was so eager to learn and watch ....thank you so much , really .
This video is great having great explanation, having two minor mistakes. 1) Top down is actually bottom up. 2) At time 29:37 it should be be T[n-1][w-wt[n-1]]
@@bokkamanideep9893 The size of value or weight array varies from 0(no element) to n (all elements) . So we have to select the size of tabulation table t[n+1][W+1] so as to accommodate all possible combinations from 0 size and weight to n size and W weight
Can you please explain why it would be w-wt[n-1] ? Isn't the second condition for the case where we are not selecting any element? When we are not selecting anything, what weight are we subtracting?
i have spent more than 4 months to only understand DP, But I must say that what you have taught in 4 videos, if i had see it earlier it will save my 4 months. very good explaination.
Bro noone literally noone has this level of understanding . the way you explained it was way better than anyone out there . in my case I never studied DP from any where 'coz I was afraid but now I am damn confident to solve any problem because now I know how to approach the problem . thank you so much bro .. and a huge respect to you . Aditya Verma OP
I might be wrong but this technique is called Bottom-Up (Tabulation) and the technique you taught in last video is called Top-Down (Memoization) technique. I have learnt basic concepts from your tutorial and it obviously helped me to understand DP fundamental concept. Thanks bro for your skills to share with us.
It's easy to find good developers out there but hard to find a good teacher. Paper pen approach is best to connect with the audience, in making them understand why something is being done and what is the thinking process to approach a problem. There could be minor mistakes here and there in what you have explained (my observations, based on the comments other viewers have left) but if the viewers can pickup on those means you have done a great job already in developing their thinking and they are following along with your explanations and thats what a teacher does :) . You have reminded me of college days where friends just used to discuss and solve problems using our basic tools -- pen, paper and friendliness of language.
I am a student in IIT , was finding it difficult to solve it many youtubers just doent tell us why we created table why we put t[i][j] = max something , but after listening to this one video whole Dynamic programming is looking easy kudos to the person , am a fan of you now
Code for all 3 approaches: Recursion => Memoization (Top down) => DP (Bottom Up) //1. Recursive Approach int knapSack(int w, int wt[], int val[], int n) { //Base Case if(n==0 || w==0) return 0;
//Choice Diagram Code //1. Choice to include item or not if(wt[n-1] w){ return 0 + knapSack(w,wt,val,n-1); } } //2. Memoize above recursive code (top-down) int knapSack(int w, int wt[], int val[], int n){ vector t(n+1, vector(w+1, -1)); return fun(w, wt, val, n, t); } int fun(int w, int wt[], int val[], int n, vector& t) { //Base Case if(n
@@the_only_one9415 No bcuz we are checking for the wt[] array....And it starts from 0 index. Here indexing for the matrix is one more than that of the input array.Hope you get it.
God level explanation brother !!! I was so afraid to start DP from much time. But when I started watching this playlist, it was so effortless for me to understand it . You made my day sir :) God bless you !!
There is a pen available that has spherical weights that move towards the end to create centrifugal force -- it makes spinning very easy. Its called, (what else) spinning-pen. There is another spinning technique where you pass the pen between all the fingers -- check it out in the 'classroom training' scene in TopGun. Who knows what I am talking about?
So far I liked your way of approach ...the great part about your video is that you show one way of approach and than to counter that you show other along with the reason of chosing the later one....it's builds up logic very effectively....will make effective use of whole playlist. Thanks sir 🙂
I was searching for such a TH-cam channel on dynamic programming that would help me think how to think and I am glad that I found your channel.. More power to you !!!
Finally someone who is teaching how to code a solution , rather than just telling the solution most of the youtubers and all my university professors just show the algo and don't give a damn about code , I am ready to pay for a course of such caliber
Bhai alag level pe samja rahe ho. Most of the people don't understand how to teach. This is the perfect example of how one should teach anything. Thanks please keep the work and continue uploading videos
Honestly, even if you pay a lot of money, you wont find the clarity with which you are explaining. Thoroughly enjoying it. Great work....Try making your videos in English also, your viewership will climb 10 folds...Also, your videos shows the huge number of hours you grinded to gain the clarity with which you are explaning. Great work and thanks a lot.
Amazing explanation, I m final year student from tier3 college. I was shit scared with coding rounds as our teachers hv nvr taught us these things. Our clg placemnt was limited to Infosys TCS, finally after watching your videos I hv gained the confidence to try for Product based companies. I will surely meet you in person once Im placed in one of those companies. Love your work bro, please keep uploading videos these are really really helpful for students like me. Thank you so much.
The beauty of your explaination is it gave me a feel as I myself have solved and analyzed the approach and solution of the problem. This is one of the best youtube videos i have ever watched!!!!!!!!!!!!!!!!!thanks keep uploading.............
I could learn and master recursion just because of you, otherwise I was always afraid of it, thanks a lot for your effort, couldn't learn things in college due to my health issue, but learning now and your videos are helping a lot, I am having 10 years of experience in IT.
bro why did u stopped uploading : ( , want series on graphs and advanced data structures too . your teaching is friendly , like we teach each other in hostels : ).
I have nothing different to say!Commenting just so the dumb youtube algorithm can see this gem and start suggesting. I was trying to learn knapsack and accidently found your playlist comment at the corner of famous video where people were struggling to understand the concept. I was skeptical and almost skipped seeing the video is in Hindi since my hindi is not so great. Somehow i watched the first one and now i am in love with this. You are such an awesome teacher , please keep doing this. Much Love.
Right, He should be more focused when writing code, I know it's easy mistake to make but we can't doubt him as well and start thinking to our self why is that.
This reminds me of dfs grid problems where instead of considering mx[r][c], they consider mx[c][r]. (mx = matrix, r = row, c = col). Has anyone seen this?
You are one of the greatest TH-camr for the learning data structure. I was having a lot of difficulties understanding the recursion. Now a concept is quite clear. I think you should start your startup similar to algoExpert. You have great potential to explain everything which no one has. Other people just discussed solution but you discussed how to reach that solution. Could you please start the videos for "FAANG" companies? Complete tutorial. I will never mind taking a paid membership for it. I solved more than 50 problems in recursion but no one tells about the choice diagram. Please let me know how did you learn those things? Did you refer to any book?
The initialization part can be done in O(n) instead of O(n*w). Use one for loop (from 0 to w) to set t[i][0] = 0 and another for loop (from 0 to n) to set t[0][i] = 0.
By far the best video on programming foundation for DP on TH-cam or any other educational site. You got an unique and excellent way of expressing complex concepts with simplicity. I hope you will create more videos.
Great Lecture on DP. Thank you very much. I am a newbie to DP but I have idea of other DS and recursion. I thought that DP is gonna be tough, but you made it easier for us. The way you approach a DP problem is awesome. I will remember your each and every words. DP jaisi h waisi likhoge to DP ka solution likh loge. Never directly start with tabulation. DP is enhanced recursion. Agar recursive calls me tree bann rha h aur overlapping subtree dikhe to DP lagega. Aur question me optimal pucha hoga
bhai aap kaise samjaathe ho ..gajab hai ... I have seen multiple videos on DP and mostly they just repeat the existing solution, but the way you mapped recursive to top-down is just amazing. I always struggled to find the top-down but never realized there is one-one mapping with recursive
after watching this video,I feel like ab toh apun hi dp ka bhagwan hai thankyou so much ,I am able to visualize everything about memoisation and tabulation now
Bro.... Really from my heart.... I thank you!. I have not been able to pass coding rounds due to questions in DP. I really feared. But the way you have explained.. just awesome!. Please go on!... Thank you! :)
Hi, great videos on DP. But I think tabulation, that is deliberately filling the table from the most solvable(or smallest) problem is the bottom-up approach. the backtracking with memo/caching is Top down, where we take the entire problem and keep hammering on it till it is broken into smallest solvable pieces and cache results for reuse
Superb Bhaiyya while other youtubers are just making us mug up the code, you came up as a live saviour! Keep uploading. Also can you please make videos on general topics like how and where to study theory subjects, how to clear online test etc. It would be really helpful
Hi Aditya, Thanks for the amazing explanation but I think at 37:26, in the 'if' condition, we should reduce the weight of the bag with previously filled item while comparing the current item's weight like 'wt[i - 1] < weightOfbag - t[i - 1, weightOfbag]'.
no, it's not required, the current item's weight that is wt[i-1] is being compared to the jth value at that time, that is the current weight the bag or knapsack is holding.
Great effort by u Man....Thanks a ton..!!! Waiting for the recursion playlist to be uploaded...I request you to please do it asap.. Till then if you can recommend any material to ace recursion would be a great help :)
Will upload more video in the month of may !! Till then keep on sharing and help this channel grow + that keeps me motivated to make more videos !! ✌️❤️
We don't have to initialize the dp matrix differently, we can do it in the same for loops, here is the c++ code // Tabulated Approach (Bottom-up)------------------------------------------ int knapSack_tabulated(int W, int wt[], int val[], int n) { vector dp(W + 1, vector(n + 1)); for (int i = 0; i
well explained by you sir. A few days ago I have seen the solution of knapsack in algoexpert ds algo series. At first time I couldn't able to understand what and how the things are going because the problem was started itself from top down approach and today you have cleared my all doubts and the multiple solutions of it. I'm very thankful to you. 🖤
Hi Aditya, I had one question, how does replacing n with i and W with j work? because we check from end of array if the item's weight is < W ie (wt[n-1]
Hi Anirudh, what you said is absolutely true. It doesn't make sense. The explanation is pretty bad imo. Not sure why people are praising a lot. There are much better videos on bottom up approach. Just see them and leave this video. This is like trying to memorising stuff without logic imo.
Engrave this in stones and history will witness that best ever tutorials created for Dynamic Programming on entire planet was created by Aditya Verma. Period.
This was what I too was wondering as this is Bottom up approach as the subproblems are solved first and then we go to the top to solve the main problem.
You are doing god's work. Very thankful to you. You tell us what we are trying to do fundamentally, which make it easy and quick to understand as compared to using definitions and bookish language. edit: I find it better to initialize value[] and wt[] arrays to n+1. this way there is no confusion in indexing it t[][].
ur explanation is so well that even before seeing this video .. and understanding how DP works , i have solved 20 DP leetcode problems nd i am continuing series now .!
do doubt one of the best teacher i am confuse in between how to convert recursive code to tabulation and you made it very simple thank you dp King.....
Finally, after 36 minutes, my anxiety of changing n,w -> I, j ended. Through out the video while you were writing the code for iterative I was like "Bhai i,j hoga .. n,w nahi !!! ". Although, I trusted you enough to watch the complete video and then you said.. "Saare n, w ko i, j me badal denge"... Anxiety Ended!
Today I got selected in Flipkart all because of your videos Aditya! Besides learning technical stuff, I got to learn from you on how to handle and approach complex problems. Thanks a lot! I really owe you a lot, can't msg on LinkedIn since you haven't accepted my request but I'm gonna ping you as soon as I join to thank you :)
your effort is really appreciable. I have taken a class in many other platforms including code blocks that too by paying 20k but yes there was only one teacher in their platform who taught the same way you taught ..rest others mug up and deliver.
Hey very good explanation, I agree on the comment that direct tabulation approach is not very intuitive to normal human mind, we have to build up the solution starting from recursion and memoization. Just one small comment, the tabulation approach is not top-down but bottom-up. It is called bottom-up, because we start the solution from base case (initialize matrix using base case) and build the solution to the top (t[n][w] in this case).
Oh yeah. of course I am glad you pointed it out. I messed up, those two terms have always been confusing to me !! 😅However our solution is still correct af, I am glad names don't effect the way you do things !! Let's just call one Memoization and the other Tabulation to avoid confusion. What I did in this solution is Tabulation. Thanks for pointing is out tho !! Keep watching and share ✌️
@@TheAdityaVerma I'd suggest adding a video after the introduction of the playlist that explains the difference between top-down (memoization) and bottom-up (tabulation). You can mention it in that video that whenever you say "top-down" in the following videos, you actually mean "bottom-up" or "tabulation". It's important that no one learns a wrong thing. Other than that, your videos are very helpful. :)
The videos are good, but even a minor mistake in standard terms also may lead to failure no matter the explanation is very good. You ought to add a frame at the start of each video that wherever you refer top-down, it is actually bottom-up, else, people will start losing faith. My intention is not from any means to hurt you, but since, your explanation is good, you need to be full-proof.
@@TheAdityaVerma So the recursive solution was top-down approach as we started at the top and kept making recursive calls until we reached the base case and then started returning values while the tabulation one was bottom up as explained in the comments, right??
@@stark_mark1107 Ya exactly.
This is just to let you know that this is the first time when someone has explained me "how to code" with such clarity! I am really very amazed and motivated today because of this video playlist.
Glad it helped you !! Please consider sharing the content with your friends or college to help this channel grow !!
@@TheAdityaVerma bhaiya yahi to prblm hai market me itna competition hai ki share karte wakt dar lagta hai actually nahi kar pata hu baki likes or comment to milega
@@TheAdityaVerma will definitely! keep on posting, love the vids
@@TheAdityaVerma Excellent Explaination. But in the GFG knapsack problem. The memoize solution is not accepting, while the top-down is accepted. There is a time limit exceeded error.
@@buzzfeedRED 0/1 knapsack or unbounded knapsack ?
I am working in IT for the last 7 years I have tried many tutorials for data structure and algorithm but no one explained like you. I really appreciate your effort. Please make the videos topic-wise from basic it can be paid or free.
Thanks a lot brother !! I am glad you liked it !!
I also felt the same way, thank you so much for time and effort Aditya Bhai. As you said all the youtubers just explained the tabular method but no one taught the same u r teaching i.e converting recursion into tabular method. hats off for your explanation and ideas. Keep uploading such problems and videos I am loving it.
Bro I am a 15 years experience engineer.. your explanation and determination to make everyone understand this topic hits hard
after 15 years why are you here for dp tutorials. i mean dp is basically caching. you might've already knew that.
@@muditkhanna8164 YOE?
@@muditkhanna8164 let her learn bro
Are you still there or retired ?
I tried learning this from hell lot of YT channels like Tushar, Jenny, Apna College, Anuj Bhaiya, even MIT Open Courseware. One word, all are trash and I could understand nothing from them! Only a true coder like you who actually works in a company and who has grinded so hard to achieve it can explain this with such clarity. Tysm brother! 💓
they aren't trash btw
Why cant I double like? This deserves a thousand likes. You opened a whole perspective of DP for me.
Using recursion first to explain and then coming to bottom up approach was a stroke of masterpiece. I've always wondered how to solve DP with tabulation but this DP series is a life saver.
First time i have seen someone connecting recursive code and tabular code like this, your method of teaching is just amazing.
In my 3rd year now, and till date I've tried to learn from so many different resources but nothing like these videos. A genuine thank you from the bottom of my heart for keeping shit real and free. Stay the same when you hit those subscriber milestones on YT because you will. And soon! ✌️💯
placement hui ky?
@@yogeshyts Haan bhai, 10LPA
@@damercy company?
@@yogeshyts It's an early stage startup man. :)
@Adarsh Chaurasia Hey thanks! :)
BROooo ....I dont know how to thank you ....I was really looking for this exact way of teaching ... and yesterday only my senior suggested me from IIT Guwahati to follow you ...and i wasn't able to sleep after seeing the way and quality of content you have provided ....i was so eager to learn and watch ....thank you so much , really .
Thanks!
Thanks for watching
this is called as TEACHING Dynamic Programming!!
great work Aditya! :)
This video is great having great explanation, having two minor mistakes. 1) Top down is actually bottom up. 2) At time 29:37 it should be be T[n-1][w-wt[n-1]]
yes exactly
Agreed
Why taking dp[n+1][w+1] for what that +1 please resolve my doubt
@@bokkamanideep9893 The size of value or weight array varies from 0(no element) to n (all elements) . So we have to select the size of tabulation table t[n+1][W+1] so as to accommodate all possible combinations from 0 size and weight to n size and W weight
Can you please explain why it would be w-wt[n-1] ? Isn't the second condition for the case where we are not selecting any element? When we are not selecting anything, what weight are we subtracting?
Didn't realize the 40 minutes were over till you said that "ab aapko samjh aa gaya hoga". That's how well you taught.
i have spent more than 4 months to only understand DP, But I must say that what you have taught in 4 videos, if i had see it earlier it will save my 4 months. very good explaination.
Bro noone literally noone has this level of understanding . the way you explained it was way better than anyone out there . in my case I never studied DP from any where 'coz I was afraid but now I am damn confident to solve any problem because now I know how to approach the problem . thank you so much bro .. and a huge respect to you . Aditya Verma OP
Hands down!!!🙌🙌 You're the BEST teacher ever!
No one has ever explained why of every single thing in DP, and you've done that ❤
I might be wrong but this technique is called Bottom-Up (Tabulation) and the technique you taught in last video is called Top-Down (Memoization) technique.
I have learnt basic concepts from your tutorial and it obviously helped me to understand DP fundamental concept.
Thanks bro for your skills to share with us.
yes buddy yuo are right
Hands down the best explanation on DP. You are helping those who cant afford to join expensive courses online. Keep it up brother !! Thanks !!
at 29:44 you take one time i as W and j as n while taking maximum .. completed 5 video and you explained very well..Pure Gem
thanks, man, for letting me understand the DP for the first time properly after 5 years of software engineering. I'm really grateful to you for this.
It's easy to find good developers out there but hard to find a good teacher. Paper pen approach is best to connect with the audience, in making them understand why something is being done and what is the thinking process to approach a problem. There could be minor mistakes here and there in what you have explained (my observations, based on the comments other viewers have left) but if the viewers can pickup on those means you have done a great job already in developing their thinking and they are following along with your explanations and thats what a teacher does :) . You have reminded me of college days where friends just used to discuss and solve problems using our basic tools -- pen, paper and friendliness of language.
Thank You So Much Brother.I Don't Think Anybody else is teaching the Crux of Dynamic Programming So well!Your Videos are Valuable for Beginners!
I am a student in IIT , was finding it difficult to solve it many youtubers just doent tell us why we created table why we put t[i][j] = max something , but after listening to this one video whole Dynamic programming is looking easy kudos to the person , am a fan of you now
Code for all 3 approaches: Recursion => Memoization (Top down) => DP (Bottom Up)
//1. Recursive Approach
int knapSack(int w, int wt[], int val[], int n)
{
//Base Case
if(n==0 || w==0) return 0;
//Choice Diagram Code
//1. Choice to include item or not
if(wt[n-1] w){
return 0 + knapSack(w,wt,val,n-1);
}
}
//2. Memoize above recursive code (top-down)
int knapSack(int w, int wt[], int val[], int n){
vector t(n+1, vector(w+1, -1));
return fun(w, wt, val, n, t);
}
int fun(int w, int wt[], int val[], int n, vector& t)
{
//Base Case
if(n
In Memoization why your code is giving the wrong input when the vector t is declared globally?
is'nt it v[i] intead of v[i-1]
@@the_only_one9415 No bcuz we are checking for the wt[] array....And it starts from 0 index. Here indexing for the matrix is one more than that of the input array.Hope you get it.
Can I please know why we require second else? when in If only we have the same statement?
The best among the ones which exist...Explaining such a hard topic in a very simple manner. Hats off
God level explanation brother !!! I was so afraid to start DP from much time. But when I started watching this playlist, it was so effortless for me to understand it . You made my day sir :) God bless you !!
This is Epic 🙌, thanks alot sir for this
One day I'll succeed in spinning pen like you.
it took me entire 11th and 12th XD
I can spin using both hands :P Thats the only thing I learnt during IIT JEE preparation. Of course its not enough to get into IIT lol :P
practice jaari hai bhai
There is a pen available that has spherical weights that move towards the end to create centrifugal force -- it makes spinning very easy. Its called, (what else) spinning-pen. There is another spinning technique where you pass the pen between all the fingers -- check it out in the 'classroom training' scene in TopGun. Who knows what I am talking about?
@@0anant0 you can spin any pen lol
So far I liked your way of approach ...the great part about your video is that you show one way of approach and than to counter that you show other along with the reason of chosing the later one....it's builds up logic very effectively....will make effective use of whole playlist.
Thanks sir 🙂
I was searching for such a TH-cam channel on dynamic programming that would help me think how to think and I am glad that I found your channel.. More power to you !!!
Finally someone who is teaching how to code a solution , rather than just telling the solution most of the youtubers and all my university professors just show the algo and don't give a damn about code , I am ready to pay for a course of such caliber
The amount of efforts put in explanation is commendable!
Thanks a lot sir!
Bhai alag level pe samja rahe ho. Most of the people don't understand how to teach. This is the perfect example of how one should teach anything.
Thanks please keep the work and continue uploading videos
Honestly, even if you pay a lot of money, you wont find the clarity with which you are explaining. Thoroughly enjoying it. Great work....Try making your videos in English also, your viewership will climb 10 folds...Also, your videos shows the huge number of hours you grinded to gain the clarity with which you are explaning. Great work and thanks a lot.
Thanks a lot for such a great comment brother. You made my day !! ❤️ Do share !!
U r too good man... I have viewed most of the utube videos on dp but no one has xplained in so much depth.. U have my respect🙏
Amazing explanation, I m final year student from tier3 college. I was shit scared with coding rounds as our teachers hv nvr taught us these things. Our clg placemnt was limited to Infosys TCS, finally after watching your videos I hv gained the confidence to try for Product based companies. I will surely meet you in person once Im placed in one of those companies. Love your work bro, please keep uploading videos these are really really helpful for students like me. Thank you so much.
best DP explanation till date either on free platform or on paid courses. :)
pehli baar top down ka matrix bana ke use kata nhi 😅😅
kudos to your effort, sir !! 🙌🙌
The beauty of your explaination is it gave me a feel as I myself have solved and analyzed the approach and solution of the problem. This is one of the best youtube videos i have ever watched!!!!!!!!!!!!!!!!!thanks keep uploading.............
I could learn and master recursion just because of you, otherwise I was always afraid of it, thanks a lot for your effort, couldn't learn things in college due to my health issue, but learning now and your videos are helping a lot, I am having 10 years of experience in IT.
Finally, I understood the lines of code. Earlier, I was getting an error.
Thanks!
bro why did u stopped uploading : ( , want series on graphs and advanced data structures too . your teaching is friendly , like we teach each other in hostels : ).
that hostel point was so damn relatable xD
He is dead bro 😭
@@mrsukki8158 stop spamming fake news
@@mrsukki8158 tera baap hoga, aditya verma nahi
@@mrsukki8158 aisa nahi hosakta
I have nothing different to say!Commenting just so the dumb youtube algorithm can see this gem and start suggesting. I was trying to learn knapsack and accidently found your playlist comment at the corner of famous video where people were struggling to understand the concept. I was skeptical and almost skipped seeing the video is in Hindi since my hindi is not so great. Somehow i watched the first one and now i am in love with this. You are such an awesome teacher , please keep doing this. Much Love.
at 29:30 in the bottom-up approach instead of t[w-weig[n-1]][n-1] it should* be t[n-1][w-weig[n-1]].
Rasik Mahajan was waiting for this comment
correct! Got me confused. Now it's all clear
Right, He should be more focused when writing code, I know it's easy mistake to make but we can't doubt him as well and start thinking to our self why is that.
This reminds me of dfs grid problems where instead of considering mx[r][c], they consider mx[c][r]. (mx = matrix, r = row, c = col). Has anyone seen this?
I was searching for this comment , I was confused too -_-
i switched to your next video but suddenly i realised that i need to say thanku for your amazing explanation and great efforts.
You are one of the greatest TH-camr for the learning data structure. I was having a lot of difficulties understanding the recursion. Now a concept is quite clear. I think you should start your startup similar to algoExpert. You have great potential to explain everything which no one has. Other people just discussed solution but you discussed how to reach that solution. Could you please start the videos for "FAANG" companies? Complete tutorial. I will never mind taking a paid membership for it. I solved more than 50 problems in recursion but no one tells about the choice diagram. Please let me know how did you learn those things? Did you refer to any book?
bruh Dil se thank you...You made things crystal clear in one go. way of explaination is also good. Hope to complete this playlist in 10 days.
The initialization part can be done in O(n) instead of O(n*w).
Use one for loop (from 0 to w) to set t[i][0] = 0 and another for loop (from 0 to n) to set t[0][i] = 0.
haa but woh abhi main nahi hai bhai, main hai yeh DP😂😂
You're 100% correct though the rest of the algo is O(n*w) anyway so it doesn't really matter Asymptomatically
bro does it matter if I write outer loop for W and inner loop for N ???
Ab ate hai yeh log , jo padhane vale k samne usko sikhate hai .
kuch bhi...isse khaali 1st row and 1st column hi initialise hoga
i never ever thought i would be able to understand tabulation(bottom-up solution) but its all becuz of you, i got this .thanks alot man
Best Dynamic programming series on TH-cam
Everything u taught in this video is on point love it🔥🔥🔥🔥.
By far the best video on programming foundation for DP on TH-cam or any other educational site. You got an unique and excellent way of expressing complex concepts with simplicity. I hope you will create more videos.
Amazing bro, so easy to follow. Keep rocking. Felt like I'm in my college days, some of my topper guys explaining me :)
Great Lecture on DP. Thank you very much. I am a newbie to DP but I have idea of other DS and recursion. I thought that DP is gonna be tough, but you made it easier for us. The way you approach a DP problem is awesome. I will remember your each and every words.
DP jaisi h waisi likhoge to DP ka solution likh loge.
Never directly start with tabulation.
DP is enhanced recursion.
Agar recursive calls me tree bann rha h aur overlapping subtree dikhe to DP lagega. Aur question me optimal pucha hoga
Fadd explanation hai bro.Your concepts are crystal clear, recursion par bhi playlist upload krdo brother
bhai aap kaise samjaathe ho ..gajab hai ... I have seen multiple videos on DP and mostly they just repeat the existing solution, but the way you mapped recursive to top-down is just amazing. I always struggled to find the top-down but never realized there is one-one mapping with recursive
You madee brave enough to encounter Algorithm and coding ❤️
I usually don't hit like button on much videos,but you have to hit like in all his videos,they all are so good
just one word bhaiya, just one:
BRILLIANT!!!!
after watching this video,I feel like ab toh apun hi dp ka bhagwan hai
thankyou so much ,I am able to visualize everything about memoisation and tabulation now
Thanku so much for this amazing lecture.......!!!!!!
Bro.... Really from my heart.... I thank you!. I have not been able to pass coding rounds due to questions in DP. I really feared. But the way you have explained.. just awesome!. Please go on!... Thank you! :)
We are just awesome ..Lot of respect and lot of love to you sir❤️
ME Wayne We?🤣
I mean u sir
bhai kya he bolu .majja he aaaa gaya ,10 times batter than college professors. recursion sikhane ke kiye eek video series bana do pls.
Thanks brother, Do subscribe and share, that keeps me motivated to do more !! and yeah its in my to-do list.
bro ur just too good
Thanks brother, share to help this channel grow !!
Hi, great videos on DP. But I think tabulation, that is deliberately filling the table from the most solvable(or smallest) problem is the bottom-up approach. the backtracking with memo/caching is Top down, where we take the entire problem and keep hammering on it till it is broken into smallest solvable pieces and cache results for reuse
Superb Bhaiyya while other youtubers are just making us mug up the code, you came up as a live saviour! Keep uploading. Also can you please make videos on general topics like how and where to study theory subjects, how to clear online test etc. It would be really helpful
200% right. Nobody could explain like this. Hats off to you man!!
Hi Aditya, Thanks for the amazing explanation but I think at 37:26, in the 'if' condition, we should reduce the weight of the bag with previously filled item while comparing the current item's weight like 'wt[i - 1] < weightOfbag - t[i - 1, weightOfbag]'.
Yes... I also noticed same
no, it's not required, the current item's weight that is wt[i-1] is being compared to the jth value at that time, that is the current weight the bag or knapsack is holding.
The best explanation of dp, Now I again have some confidence.
I saw tons of video dp but this is the best.
Great effort by u Man....Thanks a ton..!!!
Waiting for the recursion playlist to be uploaded...I request you to please do it asap..
Till then if you can recommend any material to ace recursion would be a great help :)
Will upload more video in the month of may !! Till then keep on sharing and help this channel grow + that keeps me motivated to make more videos !! ✌️❤️
Hatsoff to your coding experience and joting down points to convert one method to another. Thanks for sharing these points.
Hi bro,
Great initiative.
Please make videos on graphs as well :)
It will be a great help.
thanks a lot bro i am really loving the series.....I cant express how i am feeling after understanding everything
We don't have to initialize the dp matrix differently, we can do it in the same for loops, here is the c++ code
// Tabulated Approach (Bottom-up)------------------------------------------
int knapSack_tabulated(int W, int wt[], int val[], int n)
{
vector dp(W + 1, vector(n + 1));
for (int i = 0; i
Thank yoooooou soo much for the code 😭
well explained by you sir. A few days ago I have seen the solution of knapsack in algoexpert ds algo series. At first time I couldn't able to understand what and how the things are going because the problem was started itself from top down approach and today you have cleared my all doubts and the multiple solutions of it. I'm very thankful to you. 🖤
aren't you mistaking iterative solution saying it top-down which rather should be bottom-up ?
Best explation of 0-1 knapsack in youtube
It helps me a lot..😊😊😊
Hi Aditya,
I had one question, how does replacing n with i and W with j work? because we check from end of array if the item's weight is < W ie (wt[n-1]
Did you figure it out? If yes can you reply with an answer.. I have the same doubt
Hi Anirudh, what you said is absolutely true. It doesn't make sense. The explanation is pretty bad imo. Not sure why people are praising a lot. There are much better videos on bottom up approach. Just see them and leave this video. This is like trying to memorising stuff without logic imo.
Thanks
Thanks for watching !
Is there any specific reason you took t[n+1][w+1] and not t[w+1][n+1]?
No, Other way around will work too !!
We don't watch videos here in channel, We watch playlists..Amazing content...
Bhai recursion sikha do acche se ek bari....... fir DP halwaa lagegi
Will be uploading more videos in may till then keep sharing to help this channel grow + thats motivates me to make more videos !! ❤️✌️
@@TheAdityaVerma Bhaiya ..in desperate need of a playlist on Recursion..!! Love your work
Make video on dp for grid
Engrave this in stones and history will witness that best ever tutorials created for Dynamic Programming on entire planet was created by Aditya Verma. Period.
Move on
lol.
Abdul Bari is a great person.
@@llliiilll3624 Ya Abdul Bari is great but not as great as him
Rachit's boasts justifies too : /
Well Gaurav sen doesn't boasts
bhai tu dil se padhata hai !! Already shared this channel with my batchmates. ThankYOU
Thanks brother !!
I am one of those jinka "recursion hi strong nai h"
bhai karte rahe kosish geeks for geeks se backtracking ke questions kar...confidence aane lagega
Bro aditya bhaiya ki recursion playlist dekhlo fhir aapko for loop bekar lagne lag jayega
@@shubhamrana412 feeling same bhai
@@shubhamrana412 Lekin using for loop is better than using recursion.
@@sonulohani using a loop can be efficient? Btw what is the time complexity of the recursive function does it depend on the recurrence relation?
This explanation is tremendous . I wish I had found this earlier!!!.Please post more and more videos!!!!
THIS VIDEO SHOULD BE RE-TITLED AS "BOTTOM UP APPROACH" WHICH IS TABULATION.
This was what I too was wondering as this is Bottom up approach as the subproblems are solved first and then we go to the top to solve the main problem.
Here Bottom Up Approach ko sikha ke , he has tried to explain that top down mein bhi vahi kara ja sakta hai .And this is top down only.
You are doing god's work. Very thankful to you. You tell us what we are trying to do fundamentally, which make it easy and quick to understand as compared to using definitions and bookish language.
edit: I find it better to initialize value[] and wt[] arrays to n+1. this way there is no confusion in indexing it t[][].
Recursion seekhlo DP Halwa lagegi
.
.
.
edit: ye kon bc dislike kar ra he
ur explanation is so well that even before seeing this video .. and understanding how DP works , i have solved 20 DP leetcode problems nd i am continuing series now .!
do doubt one of the best teacher i am confuse in between how to convert recursive code to tabulation and you made it very simple
thank you dp King.....
Finally, after 36 minutes, my anxiety of changing n,w -> I, j ended. Through out the video while you were writing the code for iterative I was like "Bhai i,j hoga .. n,w nahi !!! ". Although, I trusted you enough to watch the complete video and then you said.. "Saare n, w ko i, j me badal denge"... Anxiety Ended!
Today I got selected in Flipkart all because of your videos Aditya!
Besides learning technical stuff, I got to learn from you on how to handle and approach complex problems.
Thanks a lot!
I really owe you a lot, can't msg on LinkedIn since you haven't accepted my request but I'm gonna ping you as soon as I join to thank you :)
This was so easy to understand. You made this scariest topic easy. Thankyou so much sir for this tutorial 😀😀🙏🙏
Bhai, itni clarity se samjhaya hai ki DP se pyar ho gya :D
bhai aap ka 41 min is equivalent to my 3hours, because you are amazing DSA teacher,
Bohot achhi video hai bhai!! Is tarah samjhane me mehnat lagti hai.... thank you so much!
your effort is really appreciable. I have taken a class in many other platforms including code blocks that too by paying 20k but yes there was only one teacher in their platform who taught the same way you taught ..rest others mug up and deliver.