01 Knapsack using Memoization | Concept of Memoization

  Рет қаралды 40,190

Techdose

Techdose

Күн бұрын

Пікірлер
@bestsaurabh
@bestsaurabh 4 жыл бұрын
What you explained is the top-down approach having recursive calls. For iterative solution where we solve the smaller problem first and build on top of that is called bottom up approach.
@techdose4u
@techdose4u 4 жыл бұрын
Yes you are right. In terms of subproblems Memoization is Top-down and Tabulation is bottom up. But I am used to talking in terms of directions in a table. If you fill top-down and left-right then it's actually bottom-up but due to direction, I am used to saying Top-Down.
@schan263
@schan263 2 жыл бұрын
@@techdose4u Thanks for clearing that up. I was a bit confused when you said top down at the end of the video.
@nagendrahegde
@nagendrahegde 3 жыл бұрын
Hey, this video actually made me understand knapsack solution! I am preparing for this big ass interview where mostly they will ask DP problems. I was struggling with the knapsack problem and could not understand well from gfg (btw, the content in gfg is great, but it was something with me that i could not somehow feeling the intuition). But after watching this video, i could easily corelate. Thanks dude!
@techdose4u
@techdose4u 3 жыл бұрын
Welcome 😀
@tusharbarman1924
@tusharbarman1924 Жыл бұрын
Better than all the other videos out there, thanks a lot man.
@development3090
@development3090 3 жыл бұрын
His voice is so satisfying.
@techdose4u
@techdose4u 3 жыл бұрын
😂
@padmaraghunathan4849
@padmaraghunathan4849 3 жыл бұрын
Sir, thanks for the crystal clear explanation!!!
@panmacabre9895
@panmacabre9895 2 жыл бұрын
your channel is the best
@akashchaudhary8066
@akashchaudhary8066 4 жыл бұрын
Sir, it's a great feeling to learn from you, one kind request though, please attach some practice problems related to the topics you teach in every video, I wanted to learn dp from a long time
@techdose4u
@techdose4u 4 жыл бұрын
I will do problems after concepts. You can practice those.
@akashchaudhary8066
@akashchaudhary8066 4 жыл бұрын
@@techdose4u Yeah you said that in your live stream, but if you can attach hand picked problem links, it'll be great help, either way you're great , keep up the good work
@kunalsoni7681
@kunalsoni7681 4 жыл бұрын
Very nice and helpful video to understanding deeply of knapsack problem 🥰😊😍
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@tahirm09
@tahirm09 4 жыл бұрын
Dear Sir, Thanks you vary much, Appreciate!!! you approach
@techdose4u
@techdose4u 4 жыл бұрын
Welcome :)
@aayush5474
@aayush5474 4 жыл бұрын
Itni raat ko upload sone hi jaa rha tha par video dekhunga😂
@techdose4u
@techdose4u 4 жыл бұрын
😀
@vivek.tiwary
@vivek.tiwary 3 жыл бұрын
In 2 d array, column should go till 10 that is the max capacity. Sometimes you are saying capacity 5, and you are calculating for 10, hell lot of confusion
@sridharanshooriya772
@sridharanshooriya772 4 жыл бұрын
16:18, result would be set to memo array when all the recursion calls been done right? I mean the program would go to the block when the computation is been over, I'm pretty confused on how memorization works. Great video, understood like a charm. Thank you ❤️❤️
@techdose4u
@techdose4u 4 жыл бұрын
Yes right. Welcome :)
@dhanviakash726
@dhanviakash726 2 жыл бұрын
Yeah Actually it's not using the mem table that we created to lookup I put a counter on that lookup block if(mem[n-1][capacity-1] != -1){ counter++; return mem[n-1][capacity-1]; } My counter value is 0 after program has finished
@codingexception6502
@codingexception6502 3 жыл бұрын
bhai result store karne ke liye mem[N][W] hoga na? ki mem[W][N] I am confused kyuki video main mem[W][N] hai but diagram(pichle slide) mein alag hai. Also ye array ka logic samaz nahi aa rha hai
@techdose4u
@techdose4u 3 жыл бұрын
Yes you are right. I must have written by mistake.Thanks for letting everyone know.
@codingexception6502
@codingexception6502 3 жыл бұрын
@@techdose4u Thanks for such a prompt reply. Ek doubt solve hogaya. another doubt is ki fibonacci example main hum ek hi array lete hai but isme 2-D array of no. of elements as row and weight as column. I am not getting it. kyuki maine jab dry run kia normal recursion wale code ka usme mujhe koi weight + num of element repeat hote hue nahi mila. I am confused because of that.
@vijayj1997
@vijayj1997 4 жыл бұрын
Great Explanation , can you explain manacher's algorithm its very confusing
@gajanoor
@gajanoor 2 жыл бұрын
Thanks a lot for the video. Appreciate your help. Shouldn't the base check be N < 0 instead of N == 0? Assuming the N value passed into the function is zero-indexed?
@abdelhakimlamnaouar9527
@abdelhakimlamnaouar9527 11 ай бұрын
how can we know if our memoization solution will be getting stack overflow or not?
@sridharanshooriya772
@sridharanshooriya772 4 жыл бұрын
*Those who are working on with Java, here's the code. Ty so much surya for helping me do it. capacity) { result =(getOptimalValue(capacity,values,weights,n-1,mem)); }else { result = Math.max(getOptimalValue(capacity,values,weights,n-1,mem), getOptimalValue(capacity-weights[n-1],values,weights,n-1,mem)+values[n-1]); mem[n-1][capacity-1]= result; } } return result; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int capacity = sc.nextInt(); int[] values = new int[n]; int[] weights = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); weights[i] = sc.nextInt(); } int mem[][] = new int[n][capacity]; for(int i = 0;i
@techdose4u
@techdose4u 4 жыл бұрын
👍
@dhanashreegodase4445
@dhanashreegodase4445 3 жыл бұрын
excellent!!!!! Thank you so much
@techdose4u
@techdose4u 3 жыл бұрын
Welcome :)
@ivanturko8881
@ivanturko8881 Жыл бұрын
Priceless!
@impatientgaming9868
@impatientgaming9868 Жыл бұрын
good one.
@syedkaja2045
@syedkaja2045 4 жыл бұрын
superb😀
@techdose4u
@techdose4u 4 жыл бұрын
Thanks
@KonNishant
@KonNishant 4 жыл бұрын
Great video, but if you will explain recursion part little bit more precise then it will be very helpful to those who gets stuck with recursion.
@techdose4u
@techdose4u 4 жыл бұрын
Recursion is in the previous video. Please comment there if you get any issues related to recursion.
@techmoon_
@techmoon_ 3 жыл бұрын
thanks a lot bro u rock
@techdose4u
@techdose4u 3 жыл бұрын
Welcome
@ajayaman46
@ajayaman46 4 жыл бұрын
Superb
@techdose4u
@techdose4u 4 жыл бұрын
Thanks :)
@maddinenianilkumar8737
@maddinenianilkumar8737 2 жыл бұрын
Sir, how to store 0/1 in a solution array to indicate which item is included and which is not?
@abhishekjaiswal2575
@abhishekjaiswal2575 3 жыл бұрын
I have a doubt that can we travel from 0 to n and increase n+1 every time. I mean can we move from left to right in weight array.
@sakshamsharma5484
@sakshamsharma5484 Жыл бұрын
I think base case should be N < 0 instead of N == 0 since we have an zero indexed array .
@mwshubham
@mwshubham 3 жыл бұрын
16:15 mem[w][n] or mem[n][w] ?
@mwshubham
@mwshubham 3 жыл бұрын
Btw amazing video learning this topic today.
@techdose4u
@techdose4u 3 жыл бұрын
I think I wrote something wrong. Please check it 😅
@mwshubham
@mwshubham 3 жыл бұрын
@@techdose4u yup no worries. Thanks for your reply.
@techdose4u
@techdose4u 3 жыл бұрын
@@mwshubham 👍🏼
@DEVANSHGOEL-dq1wh
@DEVANSHGOEL-dq1wh 3 жыл бұрын
thank you sir
@techdose4u
@techdose4u 3 жыл бұрын
Welcome
@isacitrabuana8689
@isacitrabuana8689 Жыл бұрын
thank you
@mpavankumar6695
@mpavankumar6695 3 жыл бұрын
Thanks
@Sandeep-lm5yi
@Sandeep-lm5yi 4 жыл бұрын
For all those looking for practice problems Here you go: atcoder.jp/contests/dp/tasks
@HimanshuSingh-ob9qo
@HimanshuSingh-ob9qo 4 жыл бұрын
👍
@techdose4u
@techdose4u 4 жыл бұрын
👍
01 Knapsack using Recursion | Building Intuition
18:38
Techdose
Рет қаралды 54 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
REAL or FAKE? #beatbox #tiktok
01:03
BeatboxJCOP
Рет қаралды 18 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Bottom Up vs Top Down Dynamic Programming vs Recursion | Fibonacci Sequence
7:26
Algorithms With Brenton
Рет қаралды 16 М.
Mastering Dynamic Programming - How to solve any interview problem (Part 1)
19:41
Identification of Knapsack problems and its Types
11:28
Techdose
Рет қаралды 26 М.
Knapsack Classification
17:35
Techdose
Рет қаралды 33 М.
0/1 Knapsack problem | Dynamic Programming
13:29
WilliamFiset
Рет қаралды 181 М.
The Change Making Problem - Fewest Coins To Make Change Dynamic Programming
23:12
Aggressive cow | SPOJ
17:54
Techdose
Рет қаралды 31 М.
5 Simple Steps for Solving Dynamic Programming Problems
21:27
Reducible
Рет қаралды 1,1 МЛН
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН