Dynamic Programming:0/1 Knapsack Problem

Поділитися
Вставка
  • Опубліковано 8 лис 2024

КОМЕНТАРІ • 130

  • @hiba3573
    @hiba3573 10 років тому +1

    I am so glad someone finally explained how the table worked! I've staring at them so long confused as to what was going on. Thank you so much!

  • @gauravtrainmanager
    @gauravtrainmanager 8 років тому

    No one was able to make me understand this knapsack but u did it very well mam...thankful to u...lv u tc.. ☺

  • @Himanshukumarh10
    @Himanshukumarh10 8 років тому +1

    Thank you, it will surely help for tomorrow's exam.

  • @asnowfall
    @asnowfall 7 років тому

    You clearly explained what is the purpose of "w-wi" in B[i-1, w-wi]. It comes at 4:40. I have spent so much time reading PDF after a PDFs, including the one shown in this video. I think Profesorrs at university should "come out their box" and take a fresh look at their PDF.

  • @h8pathak
    @h8pathak 7 років тому

    This was the EXACT content I was looking for.
    This video helped me understand this concept and pass my semester too.
    Btw I saw this nearly 3 years ago and came back to say "Thanks".

  • @jonathanstrahl535
    @jonathanstrahl535 8 років тому

    Worth adding for completion that if weight < 0 in the table the value is minus infinity. So that when w-w_j < 0 the value is not taken.

  • @francescapopescu6131
    @francescapopescu6131 9 років тому +9

    you should work on your explaining skills because you tend to stammer a lot but other than that, i think this is the best video on knapsack i've found so far so thanks! :)

    • @eddystanciu3415
      @eddystanciu3415 9 років тому

      Francesca Popescu no. balbalbalbal

    • @francescapopescu6131
      @francescapopescu6131 9 років тому

      Eduard Stanciu boss asta chiar explica bine :))

    • @vishalreddy3531
      @vishalreddy3531 7 років тому

      i started watching after reviewing all negative comments....after urs i started to watch and thankyou for your honest comments.it helped me to understand

  • @karanthorecha
    @karanthorecha 8 років тому

    this video saved me in the last moment from my exams...Thanks

  • @venkatasriharshakuncham5546
    @venkatasriharshakuncham5546 9 років тому

    The video is so good.I understood the topic very well. The approach is exemplary

  • @harshit7656
    @harshit7656 9 років тому

    Best explanation of 0-1 Knapsack so far... Thank You.. :)

  • @San13692
    @San13692 10 років тому

    that's seriously great tutorial with proper explanation of examples...without a bit of confusion..thanks :)

  • @muffin4484
    @muffin4484 9 років тому

    Well, that helped. Term Final is near and that was a savior. Thank you!

  • @aarushirai1610
    @aarushirai1610 10 років тому

    Thankyou so much for your help :) Awesome tutorials :D Please keep uploading more. LOVE THEM!!

  • @superpratik1994
    @superpratik1994 7 років тому

    thank you so much for uploading this video. you have no idea how much it's helped me!!!

  • @VC-kj9yx
    @VC-kj9yx 8 років тому

    very nice explanation much better and shorter than other videos can be used in exam as time is less there

  • @plaifaha.2674
    @plaifaha.2674 8 років тому

    I understand this algorithm because of you , thank you.

  • @kidou123456
    @kidou123456 9 років тому

    Thank you so much for your video that helps me unwind this twisted Knapsack problem!

  • @shendryrosero1524
    @shendryrosero1524 9 років тому

    thank you, The better explanation than i have ever seen

  • @abubakarkaleem1607
    @abubakarkaleem1607 8 років тому

    Good job mam! but i have a question tell me the pros and cons of knapsack, coin changing, cutting rod problem.

  • @dadauniversity
    @dadauniversity 9 років тому

    thanks a lot ...
    its gonna work in my semester exams .great job

  • @akeshav5269
    @akeshav5269 8 років тому +1

    for weight =4 max item =2 he can also take 2 weight+2weight = 6 benefit instead of (3+1) wight = 4

    • @umarriqbal
      @umarriqbal 8 років тому

      +keshav aske Har item ki quantity one hai, bruv.

    • @AkashGupta-dk2dy
      @AkashGupta-dk2dy 6 років тому

      for item 2 weight is 3kg so subtracting 4-3kg= 1kg which eventually gives 0 and 0(1kg)+4(3kg)=4

  • @raselmahmud6888
    @raselmahmud6888 9 років тому

    Knapsack problem is no more problem for me ..
    thaks for this upload

  • @somi105
    @somi105 8 років тому

    If this were an unbounded knapsack problem, would row 1, column 4 have a value of 6? Because the weight of the first item is only 2 kg and in the 4th column, our knapsack has a capacity of 4 meaning 2 kg is still left. Therefore another copy of the first item can fit? Obviously, more changes would occur throughout the table but I am just giving one example. I am just trying to understand this for my own sake.

  • @joejavacavalier2001
    @joejavacavalier2001 7 років тому +1

    I have a stupid question. (Well ,it probably is....) Are you supposed to sort the items by weight before using the algorithm to create the matrix?

  • @AbhishekSinghBhadauria
    @AbhishekSinghBhadauria 10 років тому

    You saved me from my exam.

  • @RahulSharma-bx4cm
    @RahulSharma-bx4cm 9 років тому

    Thanks.. A short and sweet description. :)

  • @youngboyab
    @youngboyab 9 років тому +1

    you are too fast.. but this helped me understand this problem way better than any other lessons.. thank you so much

  • @somyagupta1327
    @somyagupta1327 9 років тому

    Very nice explanation........tommorow is my exam....

  • @jacquesholmes4193
    @jacquesholmes4193 8 років тому

    Hi can I know which software you used for recording the screen and also the software that you drew the problem on. Just for my course project. Thanks.

  • @markganus1085
    @markganus1085 9 років тому

    I've been looking for it. thanks heaps

  • @saif0316
    @saif0316 3 роки тому

    This explanation was so clean

    • @saif0316
      @saif0316 3 роки тому

      Why is it 4-2 here?

    • @saif0316
      @saif0316 3 роки тому

      9:47 I mean like, why did we take 4-2 =2. And then get 3 from row 2 and add that to 4 to get 7, here?

    • @saif0316
      @saif0316 3 роки тому

      Why is it not 1kg remaining?

  • @negar21100
    @negar21100 10 років тому

    Nice explanation, but could you/somebody interpret the final result? Im wondering how we can judge about the optimal choice based on the last cell in the table?

  • @stronggjk8492
    @stronggjk8492 9 років тому +2

    what if there is another constraint such as cost?

  • @nithin1664
    @nithin1664 8 років тому

    I have a doubt, how to solve it if the knapsack capacity is a fractional value eg. 5.5 kg ?

  • @blogwithabhik
    @blogwithabhik 10 років тому

    I still have a doubt..can u please help? While doing the calculation for 2nd item.. on the 4kg why did you subtracted 3 from 4 and got the weight 1Kg left..!! I mean our max weight is 5kg..so if we want to check how much more weight we can take we should do 5-3=2Kgs instead of 4-3=1kg ..Right?? Plz help!

    • @JubayerRony
      @JubayerRony 9 років тому +2

      for the "column 4 kg". u can take total 4 kg highest. that's why it's 4-1. If we did it for "column 5 kg", it would be 5-3.

  • @hanumanthk7059
    @hanumanthk7059 8 років тому

    Thanks a lot Madam. Excellent Explanation.

  • @TheRahuluppal
    @TheRahuluppal 9 років тому

    1 question..when we are taking weight 4kg with 2 items, its ok that we took benefit of 7 for 3 kg but for remaining 1kg why are looking for its benefit in previous row , previous row was for 0 items,isn't it??

  • @hishamelamir2815
    @hishamelamir2815 9 років тому

    I loved this video , great work

  • @yogendramiraje8962
    @yogendramiraje8962 9 років тому

    Very nice explanation. I appreciate your efforts ! Can you give the link to the material/slides you are referring in the video? It will be of great help !

  • @vishalreddy3531
    @vishalreddy3531 7 років тому

    2017 ..still best vid on knapsack

  • @saqueebabdullah9142
    @saqueebabdullah9142 8 років тому

    Hello apu, at 10:14 you said as its 4th kg you are taking the item containing 4kg and wrote benefit 5. However, I can take the item of weight 2kg which has the benefit of 3 and go back to the cell 2 and add the benefit.
    2kg(3)+ Benefit of Cell(2) [For 4th kg]
    3+3=6
    So, shouldn't I take 6 instead of taking 5?
    Can you please give the feedback as soon as possible, I have CSE221(Algorithm) exam tomorrow.
    Thank you! :)

  • @youtubeDaddy525
    @youtubeDaddy525 8 років тому

    Thank you ! You are my life savor

  • @umarriqbal
    @umarriqbal 8 років тому

    THIS WAS VERY HELPFUL.

  • @MrBravery103
    @MrBravery103 9 років тому

    Thanks :). How do i backtrack and find out what items you need to pick to get the max weight? This algorithm gives us the max weight he can carry; But what items should he select to get that weight which was obtained ?

  • @mexart3826
    @mexart3826 10 років тому

    Why does the beneffit of 5 change from 9 to 6? shouldnt it be (5,9) ??

  • @rohansharma8236
    @rohansharma8236 10 років тому

    Thanks alot dear...I'm grateful for your help. :)

  • @JoseTorres-tr6od
    @JoseTorres-tr6od 9 років тому

    So, should the items be sorted by weight?

  • @akshitkumar007
    @akshitkumar007 9 років тому

    tnx....Dat helpd for my tomm's Exam.....Tnx Alot,,,

  • @CherryPauper
    @CherryPauper 9 років тому

    If you were on item 2, why were you looking at item 3?

  • @AshishTaunk
    @AshishTaunk 8 років тому +1

    I think You should first explain the recursive relation before applying it to fill the table.

  • @markthomas9372
    @markthomas9372 7 років тому

    what if the total weights and items are given as 100 50 20 10 7 3.??? can u gimme the solution?? how do I compute it in table??

  • @seemaverma279
    @seemaverma279 10 років тому

    how can i can i solve this problem if
    M=165. n=6,
    (p1,p2,p3,p4,p5,p6)=(w1,w2,w3,w4,w5,w6)=(100,50,20,10,73).
    solve knapsack problem using dynamic programing.

  • @MySanjukta
    @MySanjukta 9 років тому

    VERY WELL EXPLAIN.....THANK YOU SO MUCH...

  • @mohammedgad5321
    @mohammedgad5321 9 років тому

    Thank you very much :D
    keep it up!

  • @MattMcConaha
    @MattMcConaha 9 років тому

    For anyone who didn't understand by watching the video, try making a table yourself. This helped me to figure it out (with the help of the video, of course.)
    Basically, the way it works is that the previous row is the optimal solution for every weight limit, assuming that only the items of that row and up are available. So the 0 row, all the answers are zero because there are zero items available to take. The 1 row is the maximum value for every weight limit from 0 to 5 when only item 1 is available. The 2 row is the maximum value for every weight limit from 0 to 5 if only items 1 and 2 are available. And so on.
    So for any given cell in the table, to find what the value should be, you compare the values if you don't take the current row's item (which will be equal to the cell above it) compared to the value if you do take the current row's item (which will be the sum of the value of the current item plus the cell from the above row at the weight limit which is equal to the remaining amount of weight that you can carry after taking the current item.)
    And trying to work out the problem by hand helped me to understand why this is reasonable.

  • @mahmudulhasannavil6499
    @mahmudulhasannavil6499 9 років тому

    At 6:33. you considered weight 4 - 3 = 1kg, for 3kg weight benefit is 7 and for 1kg benefit is 0. so 7+0 =7, benefit for 4kg. Why didn't u considered 3+1=4kg, for 3kg weight benefit is 7 and for 1 its 0, 7+0 = 7??

  • @shivampandya7649
    @shivampandya7649 9 років тому

    thank you so much. It helped a lot

  • @AakarshRaghunath
    @AakarshRaghunath 7 років тому

    Great video, helped a lot ^^!

  • @Thuggerist
    @Thuggerist 9 років тому

    I love you. Thank you so much!

  • @DawningLight203
    @DawningLight203 8 років тому

    Awsome explanation .... :)

  • @IshanVermarangers
    @IshanVermarangers 9 років тому

    Thanks for sharing! :D

  • @srihariharans
    @srihariharans 9 років тому

    Thank You.. but I hope it could have been explained in much more fun fashioned way!!

  • @rohitnaik6221
    @rohitnaik6221 9 років тому

    U EXPLAINED WELL.... THANX

  • @kumbhajverma9090
    @kumbhajverma9090 7 років тому

    nice explanation, and i love ur voice

  • @govind10d
    @govind10d 9 років тому

    Love you !! tut is awesome ..

  • @quinston
    @quinston 9 років тому

    That really helped! Thank you!

  • @md.mahadyhasan8456
    @md.mahadyhasan8456 10 років тому

    well explained... thanks a lot..

  • @malekmatinziraksaz6802
    @malekmatinziraksaz6802 5 років тому

    very good explanation

  • @ruhulmashbu4751
    @ruhulmashbu4751 8 років тому

    apu is it a top down approach or a bottom up ??

  • @aryamukherjee2443
    @aryamukherjee2443 7 років тому

    Thank you ma'am... understood :-)

  • @mrherix7568
    @mrherix7568 9 років тому

    Idk where this particular problem comes from but it makes things more tricky than they need to be. Why in heaven would a bag of 4kg of gold have a lower benefit then a bag of 2kg?

  • @lanmisu
    @lanmisu 10 років тому +1

    Wow, i got it right away. I am asking myself is it real algorithms or ???? cos i have seen other video which i don't understand. U are my hero. THanks a lot!!! how about if the question is minimum weight?

    • @gabrielguedes6643
      @gabrielguedes6643 10 років тому +1

      I would guess the minimum weight is always zero...

  • @saifalikhan3278
    @saifalikhan3278 9 років тому

    Thank u for such a nice tutorial...
    please share your blog link..

  • @hanmantpatil7498
    @hanmantpatil7498 9 років тому

    thanks.. needed it :)

  • @TheFazilaashraf
    @TheFazilaashraf 8 років тому

    dear mifta you are ausam

  • @nimaaghli
    @nimaaghli 10 років тому +3

    Thank you

  • @hakanpelit3538
    @hakanpelit3538 9 років тому

    Thank you so much :)

  • @akashsky9431
    @akashsky9431 8 років тому

    Very Helpful. :-)

  • @mohitpawar10
    @mohitpawar10 9 років тому

    good explanation.......!!!thank U....

  • @andykelly7321
    @andykelly7321 9 років тому

    I have absolutely no idea what any of that meant. Sounded good though lol

  • @ThanhNguyen-vk5kf
    @ThanhNguyen-vk5kf 9 років тому +3

    Maybe u should give pseudocode
    for i: = 0 to M do cost[i]: = 0;
    for j: = 1 to N do /* each of item type */
    begin
    for i:= 1 to M do /* i means capacity */
    if i - size[j] > = 0 then
    if cost[i] < (cost[i - size[j]] + val[j]) then
    begin
    cost[i]: = cost[i - size[j]] + val[j]; best[i]: = j
    end;
    end;

  • @nillnoyon4949
    @nillnoyon4949 9 років тому

    really i enjoyed it :)

  • @stjepandalic8205
    @stjepandalic8205 8 років тому

    Thank you!

  • @ShahairDar
    @ShahairDar 8 років тому

    very helpful :)

  • @justint3402
    @justint3402 9 років тому

    No traceback?

  • @KesavarapuVenkatesh
    @KesavarapuVenkatesh 9 років тому

    Superb.... helpfull

  • @kk420100
    @kk420100 10 років тому

    good one ...keep it up

  • @akashkulkarni3111
    @akashkulkarni3111 8 років тому

    plz can u give me its complete algorithm....!!!
    so they that we can relate each steps will solving rhe example..
    u have done a great jpb..!!!thank you

  • @IntoTheSettingSky
    @IntoTheSettingSky 9 років тому

    "column 5 kg + column row - 6 kg + 1 = 10 kg so we keep 10 kg because 5-2 = 3!"
    Fuck

  • @Exzamp
    @Exzamp 9 років тому

    Thanks a ton.

    • @Exzamp
      @Exzamp 9 років тому

      Exzamp i meant 1000 khey gee

  • @xaviershelton5129
    @xaviershelton5129 9 років тому

    hmm I never used this in class Thanks

  • @chiragshahckshhh9696
    @chiragshahckshhh9696 8 років тому

    Tysm!! it was good ...

  • @MrA-pc4kp
    @MrA-pc4kp 9 років тому +1

    ThanQ....

  • @AbdurRehman-eo4gr
    @AbdurRehman-eo4gr 9 років тому

    so fast come on girl,slow down,keep calm and tech calm :)

  • @ruffyistderhammer5860
    @ruffyistderhammer5860 6 років тому

    perfext

  • @saifurrahmanbhuiyan925
    @saifurrahmanbhuiyan925 9 років тому

    nice job

  • @AlpBarazi
    @AlpBarazi 8 років тому

    thanks :)

  • @magiccouponsREAL
    @magiccouponsREAL 9 років тому

    2nd diagram no way as clear as the first. Other than that good stuff

  • @musazizhou8217
    @musazizhou8217 10 років тому

    waita basa, thank you

  • @shovonmajumder2372
    @shovonmajumder2372 9 років тому

    Mifta Apu ROCKZZZZZZZZZZ