01 Knapsack using Recursion | Building Intuition

  Рет қаралды 55,517

Techdose

Techdose

Күн бұрын

Пікірлер: 138
@rimzb
@rimzb 3 жыл бұрын
Thanks
@rimzb
@rimzb 3 жыл бұрын
This is a small token of thanks for the knowledge I have received from watching your videos. I have started studying DS and Algos all over again after a decade to prep for interviews. I used to get bored and demotivated after a while and the LC solutions can sometimes be tricky to understand almost to the point of giving up, but your explanations, diagrams and points are so easy to understand and remember. They are also addictive to watch, lol. The fact that you can keep your students engaged and interested in the content truly makes you an amazing teacher! I hope more people benefit and contribute to your channel :) Thank you so much for your hard work and effort!
@Sky-nt1hy
@Sky-nt1hy 4 жыл бұрын
wtf i seriously don't understand why you have only 38K subs. I've been working on Algorithm on my own for the last 6 months and have seen more than 100 channels. They're all great but I have never seen a channel better than yours. I will spread this out to help more people. Thanks always bro.
@Sky-nt1hy
@Sky-nt1hy 4 жыл бұрын
maybe you should do more ad or some commercials this channel is extremely underrated
@techdose4u
@techdose4u 4 жыл бұрын
Thanks for your support bro :)
@techdose4u
@techdose4u 4 жыл бұрын
Ad will cost good amount of money which I don't have right now 😅 So, I am relying on word of mouth to spread the existence of this channel. Thanks for helping.
@Sky-nt1hy
@Sky-nt1hy 4 жыл бұрын
@@techdose4u Your sub# is too low for this quality. I am thankful for this channel so much! I will try to go over as much as possible before the interview. Always cheers!
@dayanandraut5660
@dayanandraut5660 3 жыл бұрын
Completely agreed
@sridharanshooriya772
@sridharanshooriya772 4 жыл бұрын
You are a life saver! Even coursera course on dsa didn't explain as beautifully as you did. Reading out of a slide made it hard to understand. Your teaching method works like a charm! I'm honoured that you do these videos balancing your work life. Thank you surya!
@techdose4u
@techdose4u 4 жыл бұрын
Welcome
@adityasarin39
@adityasarin39 4 жыл бұрын
This explanation is the best I have ever found for recursion! Covering each and every small detail, step by step 👌
@techdose4u
@techdose4u 4 жыл бұрын
Nice :)
@sanskarrawat1047
@sanskarrawat1047 3 жыл бұрын
Kabhi aditya verma ka naam suna h?
@Luckyankii
@Luckyankii 2 жыл бұрын
@@sanskarrawat1047 na sunnA HOGA PAKKA YE
@PujaKumari-rp5sg
@PujaKumari-rp5sg 6 күн бұрын
Whenever I don’t understand something, the first thing I do is search for a video on your channel. Before watching your video, a sense of relief comes to mind because if your video is available for this problem, I know I will surely be able to solve it. Thank you so much!❤❤❤! People like me who was thinking I couldn’t do DSA, I’m now confident and solving DP problem . Next, the last topic is graphs for me 😊
@hardiksrivastava6395
@hardiksrivastava6395 3 жыл бұрын
This is by far the BEST explanation compared to all coding platform giants. Your videos on DSA are superb and to the point. Much much appreciation and love !! You are great !!!!
@pramodsharma4508
@pramodsharma4508 4 жыл бұрын
I think you should do more dp problems with their recursive solution first...it really helps in building the thought process of the problem...
@techdose4u
@techdose4u 4 жыл бұрын
Yea sure
@sommayghosh4617
@sommayghosh4617 4 жыл бұрын
@@techdose4u yes sir ur way to approach the problem is very nice it helps to build intuition , please continue building this playlist!
@yianchen1553
@yianchen1553 5 ай бұрын
thank you; you're a godsend. you have helped me understand so many concepts that i previously couldn't grasp.
@AlbtzGaming
@AlbtzGaming 4 жыл бұрын
You make us falling love in coding !! Thank you very much for your effort !!!
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@prabhatmishra6753
@prabhatmishra6753 3 жыл бұрын
I was very furious about English explaination but when I started watching him , his explanation is enough to understand you what actually a code wants from you as well as very clear explanation
@techdose4u
@techdose4u 3 жыл бұрын
Thanks ☺️
@nicknack9908
@nicknack9908 4 жыл бұрын
This was a great explaination! Helped me a lot with my coding homework in university, which I could not solve. (Currently studying computer science in Germany.) Keep the great work going! :)
@techdose4u
@techdose4u 4 жыл бұрын
Thanks for your appreciation :)
@abhijitroy1958
@abhijitroy1958 3 жыл бұрын
best explanation till now of knapsack
@maryam1777
@maryam1777 Жыл бұрын
Man my God keep you in great happiness.. YOU ARE MY LEGEND
@haqinzmamul12
@haqinzmamul12 2 жыл бұрын
Bro I scroll upto 10 times down videos on KZbin for dp there are so many great I watched all of them one by one but you're hero among all of them.... keep going you'll be remarkable one day
@sridharanshooriya772
@sridharanshooriya772 4 жыл бұрын
The naive approach was explained intuitively. Thank you!
@techdose4u
@techdose4u 4 жыл бұрын
Welcome ;)
@123liveo
@123liveo 2 жыл бұрын
This explanation is absolutely superb. This at the next one about memoization really helped. Recommending it on my uni algorithm course. Cheers!
@kush-cp8kc
@kush-cp8kc 2 жыл бұрын
thank you so much for this much detailed and pin poined thing ....it was really really helpful and the best till now... .
@noc12
@noc12 2 жыл бұрын
I am following this channel when it has 10k..finally got what u deserve..congrats for 100k subs
@techdose4u
@techdose4u 2 жыл бұрын
Thanks 🙏🏼
@mikekibet1786
@mikekibet1786 4 жыл бұрын
Best explanation ever. I am subscribing this very minute
@techdose4u
@techdose4u 4 жыл бұрын
👍
@physicsmathsworld2033
@physicsmathsworld2033 2 жыл бұрын
Brilliant Teacher ❤️❤️
@ihsannuruliman3656
@ihsannuruliman3656 2 жыл бұрын
this is a great channel, even better than I was thought.
@大盗江南
@大盗江南 3 жыл бұрын
These videos are amazing.buddy. Just amazing...i finally understamd
@techdose4u
@techdose4u 3 жыл бұрын
Great ❤️
@malikwaseem1983
@malikwaseem1983 4 жыл бұрын
This is explained really well. Thanks Tech Dose. I love your channel.
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@manoranjaniiit
@manoranjaniiit 4 жыл бұрын
Simply awesome explanation
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@krishnasalampuriya1311
@krishnasalampuriya1311 3 жыл бұрын
Very helpful 👍
@renon3359
@renon3359 4 жыл бұрын
Thanks for the great videos man, I am learning DP from your playlist only, and I haven't done DP ever before.
@techdose4u
@techdose4u 4 жыл бұрын
Great bro :)
@techmoon_
@techmoon_ 3 жыл бұрын
best lecture bro great explanation
@techdose4u
@techdose4u 3 жыл бұрын
Thanks :)
@ChandraSekhar-tr7sf
@ChandraSekhar-tr7sf 2 жыл бұрын
Excellent 👌
@shoumeshrawat1362
@shoumeshrawat1362 3 жыл бұрын
You explain so well .. Thnk you so much
@techdose4u
@techdose4u 3 жыл бұрын
Welcome
@RCavivhal
@RCavivhal 2 жыл бұрын
Thank u for this tutorial, great explanation. Really appreciate it
@rehanakhter4813
@rehanakhter4813 4 жыл бұрын
I am waiting for combination sum with all its variations. Please introduce it. Thanks for the good work.
@techdose4u
@techdose4u 4 жыл бұрын
I will upload it someday :)
@abirmoulick866
@abirmoulick866 4 жыл бұрын
Great explanation. I want to know whats the advantage of traversing array from back (n-1 to 0). I have seen it many times in other codes.
@dineshothamkumar
@dineshothamkumar 2 жыл бұрын
It is to satisfy the generic principle of Recursion that goes from N to base case. Here, the base case is N=0 that is no item to process.
@rajatnagpure7445
@rajatnagpure7445 4 жыл бұрын
waiting for video on Travelling salesman problem. Be it in graph theory or DP playlist.
@techdose4u
@techdose4u 4 жыл бұрын
It will come in graph playlist. I will cover those topics later. There are some topics left in graph. But everyone was requesting for DP to start ASAP, so I left graph for now. I will resume it only after finishing easier topics.
@CodingRegion
@CodingRegion 2 жыл бұрын
Thank you for this video💙 This is so helpful 🥺
@devprakash5320
@devprakash5320 4 жыл бұрын
sir, you explained it beautifully .
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@abhishekkumarjhariya1340
@abhishekkumarjhariya1340 3 жыл бұрын
Great explanation .
@letsdoeverythinginoneweek9398
@letsdoeverythinginoneweek9398 3 жыл бұрын
thank u sir for making this dp series is this dp series is enough to clear our all dp concepts
@techdose4u
@techdose4u 3 жыл бұрын
Almost all for interview
@amitp277
@amitp277 3 жыл бұрын
great explanation 👍🏻
@bhawnasingh8114
@bhawnasingh8114 3 жыл бұрын
Best explanation!!
@techdose4u
@techdose4u 3 жыл бұрын
Thanks
@shiyamabhisak4778
@shiyamabhisak4778 3 жыл бұрын
This is the best explanation for recursion I,ve heard till now ,Your way of explanation is very nice and helpful for me to understand each and every step in detail.
@techdose4u
@techdose4u 3 жыл бұрын
Thanks 😊
@rishabhratan2925
@rishabhratan2925 4 жыл бұрын
wont it be (n-1) in the skip case?
@naman_goyal
@naman_goyal 4 жыл бұрын
Very nice
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@DEVANSHGOEL-dq1wh
@DEVANSHGOEL-dq1wh 3 жыл бұрын
Thank you very much
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@sridharanshooriya772
@sridharanshooriya772 4 жыл бұрын
14:06 if we skip the item, the profit will obviously be lesser of the included right? Or... Skipped item will recur to its previous items and return the profit?
@lakshmivishnu6594
@lakshmivishnu6594 4 жыл бұрын
Excellent, Thank you!!!! :)
@techdose4u
@techdose4u 4 жыл бұрын
Welcome
@jagdishsahoo8232
@jagdishsahoo8232 3 жыл бұрын
Sir your explanation is awesome...It will be best if you can provide the questions links of the problems of the theory covered, from which we can practice :)
@techdose4u
@techdose4u 3 жыл бұрын
👍🏼
@harshitchoukse2602
@harshitchoukse2602 3 жыл бұрын
The base condition should be if(n
@kr_ankit123
@kr_ankit123 3 жыл бұрын
you are right bro👍👍
@harshitchoukse2602
@harshitchoukse2602 3 жыл бұрын
@@kr_ankit123 but later on , I understood that he is explaining from 1 based indexing.
@ajithpalani5139
@ajithpalani5139 4 жыл бұрын
Clear cut explaination,Favourite teacher ever.Keep Rocking sir.Thank u sir🔥😍🔥
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@rshmvarma
@rshmvarma 3 жыл бұрын
This was amazing.
@techdose4u
@techdose4u 3 жыл бұрын
Thanks :)
@dayanandraut5660
@dayanandraut5660 3 жыл бұрын
if N = (length of W)-1, then your base condition should be like this if (N==-1 || W==0) return 0 if N = (length of W), then your other condition should be like this if(wt[n-1]>w)......
@nahman1105
@nahman1105 2 жыл бұрын
Great video, thank you! How could I also output the volume along with the value of the knapsack?
@Trishul-Industries
@Trishul-Industries Жыл бұрын
his explanatation is much more similar to Aditya varma explanation for same question. Both are super
@Kaa-rj4on
@Kaa-rj4on 5 ай бұрын
Do you have the code in any git repo or somewherer...?
@rangapavankumar79
@rangapavankumar79 4 жыл бұрын
If we use this in any online contest it is able to pass all the test cases?? As the time complexity is 2power(n)
@techdose4u
@techdose4u 4 жыл бұрын
No it won't pass all test cases anywhere. For that you need to use DP. I will be explaining how to write DP code in next video.
@mdimranhosen6674
@mdimranhosen6674 3 жыл бұрын
💚
@techdose4u
@techdose4u 3 жыл бұрын
Thanks 😊
@mayankchauhan6680
@mayankchauhan6680 3 жыл бұрын
Thanks, Algo Buddy. By the way, this one is much like backtracking.
@techdose4u
@techdose4u 3 жыл бұрын
True :)
@extraspecialgyan7052
@extraspecialgyan7052 10 ай бұрын
op sir ji
@lakshmivishnu6594
@lakshmivishnu6594 4 жыл бұрын
Hey, Are you planning/giving any private tuition ( one-one online or in-person ( especially focusing on the effective c++ by Scott Meyers approach ) on C++? If it is so, is it possible to send you a private message to discuss further?
@pranavyeleti3499
@pranavyeleti3499 2 жыл бұрын
in recurssion can we start from i=0 to i=N-1
@nitinmahajan3320
@nitinmahajan3320 4 жыл бұрын
Why do we start from last element of array (N-1)? Naturally I will start from 0th element of array till N-1. Are there any benefits or challenges in thinking reverse?
@techdose4u
@techdose4u 4 жыл бұрын
You can start from beginning. No problem
@bruhbrh7266
@bruhbrh7266 Жыл бұрын
i am getting wrong solution with the base case N==0, it wont calculate the 0th i of the array (the first element). putting n
@HimanshuSingh-ob9qo
@HimanshuSingh-ob9qo 4 жыл бұрын
👍
@techdose4u
@techdose4u 4 жыл бұрын
👍
@rishviks8987
@rishviks8987 4 жыл бұрын
Sir, I think the same could be done using backtracking 🤔
@ADITYASINGH-og9ml
@ADITYASINGH-og9ml 4 жыл бұрын
Make a video on painter partision problem its difficult to solve
@techdose4u
@techdose4u 4 жыл бұрын
Already made
@259_parthpatidar9
@259_parthpatidar9 3 жыл бұрын
wow
@techdose4u
@techdose4u 3 жыл бұрын
😊
@mahipalsingh-yo4jt
@mahipalsingh-yo4jt 4 жыл бұрын
sir I am not form cs background , so how much time it will take to cover cs subjects for placement preparation. I have watched your video in which you said to complete them in 2 days per subject. Will 2 days be sufficient for a placement in big companies. Please reply.....
@techdose4u
@techdose4u 4 жыл бұрын
You will need longer time. 2 days is just for revision. You can finish a subject in 10 days.
@mahipalsingh-yo4jt
@mahipalsingh-yo4jt 4 жыл бұрын
@@techdose4u thanx sir ..
@matthieuguimard2236
@matthieuguimard2236 3 жыл бұрын
Your video is very clear thankyou for making it. However i am trying to adapt it in order to save the optimal configuration the recursion find. With your code I only have the maximum profit but the configuration is transparent. I thought abour builind a binary tree but i am struggling with it. Would someone has an idea?
@techdose4u
@techdose4u 3 жыл бұрын
Hi. Building a binary tree ? Why
@matthieuguimard2236
@matthieuguimard2236 3 жыл бұрын
@@techdose4u I want to keep the optimal decision tree. I understand that with your algorithm I have the maximum possible profit but i don't know wich configuration leeds to this maximum profit. I don't know if the binary tree is the good solution but it is just the intuition I've had. Each decison ( 'take it' or 'not take it') would create a new branch. When the algo is over, I would just have to parse the good configuration from the tree.
@heybeachMIN
@heybeachMIN 2 ай бұрын
I think there's basic-case a little bit not right, coz n could be < 0, so you need make n
@dineshbabu3227
@dineshbabu3227 4 жыл бұрын
Shouldn't the basecase be this?? if(n
@dineshbabu3227
@dineshbabu3227 4 жыл бұрын
I changed input as weights {4, 3, 2} and profit {7, 6, 8} Output: 14 when n==0 15 when n
@gugli28
@gugli28 4 жыл бұрын
the approach is same as printing all subsequence of a string
@syedkaja2045
@syedkaja2045 4 жыл бұрын
understand everything but i cant understand the else case pls dry run the code with some example:)
@techdose4u
@techdose4u 4 жыл бұрын
Else case has 2 options. You can include or exclude a current item. We will take that option which gives us maximum profit.
@spetsnaz_2
@spetsnaz_2 4 жыл бұрын
If weight of current element is greater than the available space, then skip it. If no of elements becomes 0 or the knapsack becomes full, then return; Else we can either include current element and go to furthur processing or we can skip this current element and go to next element for processing because this element may give us lower profit compared to other elements
@syedkaja2045
@syedkaja2045 4 жыл бұрын
@@spetsnaz_2 oh ok i understand ;)
@syedkaja2045
@syedkaja2045 4 жыл бұрын
@@techdose4u thanks :)
@asashish905
@asashish905 4 жыл бұрын
@@spetsnaz_2 how to check the may part?? May give lower profit part?? Can somebody tell me about the max method plz?
@yitingg7942
@yitingg7942 3 жыл бұрын
Recursion is indeed hard.. No matter how many times I have seen them and used them I am still so scared of them.... 啊😔😔😔
@techdose4u
@techdose4u 3 жыл бұрын
Recursion is all about visualisation. Once you can do it, recursion will feel as easy as bruteforce method :)
@audiobooksforyouspark
@audiobooksforyouspark 3 жыл бұрын
wow
@anonymoussloth6687
@anonymoussloth6687 3 жыл бұрын
base case should be N==-1 || W == 0
@MathematicalCowboy
@MathematicalCowboy 3 жыл бұрын
Great explanation! However, this approach doesn't reveal the correct combination of items, only the maximum profit to be had by choosing those items.
@tech_wizard9315
@tech_wizard9315 4 жыл бұрын
6 months roadmap please to crack google for 2020passouts
@neerajseth6566
@neerajseth6566 2 жыл бұрын
Profit(n) should be Profit(n-1).
@Cloud-577
@Cloud-577 2 жыл бұрын
Thank you so much
01 Knapsack using Memoization | Concept of Memoization
18:03
Techdose
Рет қаралды 40 М.
黑天使只对C罗有感觉#short #angel #clown
00:39
Super Beauty team
Рет қаралды 36 МЛН
The evil clown plays a prank on the angel
00:39
超人夫妇
Рет қаралды 53 МЛН
The 0/1 Knapsack Problem (Demystifying Dynamic Programming)
20:30
Back To Back SWE
Рет қаралды 211 М.
Knapsack Classification
17:35
Techdose
Рет қаралды 33 М.
0/1 Knapsack problem | Dynamic Programming
13:29
WilliamFiset
Рет қаралды 189 М.
0-1 Knapsack Problem (Dynamic Programming)
9:20
CS Dojo
Рет қаралды 496 М.
Identification of Knapsack problems and its Types
11:28
Techdose
Рет қаралды 26 М.
4.5 0/1 Knapsack - Two Methods - Dynamic Programming
28:24
Abdul Bari
Рет қаралды 3,1 МЛН
5 Simple Steps for Solving Any Recursive Problem
21:03
Reducible
Рет қаралды 1,3 МЛН
5 Simple Steps for Solving Dynamic Programming Problems
21:27
Reducible
Рет қаралды 1,1 МЛН