7.2 0/1 Knapsack using Branch and Bound

Поделиться
HTML-код
  • Опубликовано: 25 фев 2018
  • 0/1 Knapsack using Branch and Bound
    PATREON : www.patreon.com/bePatron?u=20...
    Courses on Udemy
    ================
    Java Programming
    www.udemy.com/course/java-se-...
    Data Structures using C and C++
    www.udemy.com/course/datastru...
    C++ Programming
    www.udemy.com/course/cpp-deep...

Комментарии • 304

  • @sriramkanisetty5083
    @sriramkanisetty5083 5 лет назад +457

    He is better than my faculty who is taking 2 lakh salary .

    • @sasidharthoneti1385
      @sasidharthoneti1385 3 года назад +10

      Which college are u studying bro

    • @ganeshtowar8050
      @ganeshtowar8050 2 года назад

      😂😂😂

    • @garlapatinikil4778
      @garlapatinikil4778 Год назад

      😂😂😂😂😂😂

    • @Ani-rw4ln
      @Ani-rw4ln Год назад +11

      This guy is earning in crores

    • @ganeshtowar8050
      @ganeshtowar8050 Год назад +23

      @@Ani-rw4ln but we pay zero rupees to him and he provides more value to us if compared to the institution than are taking 2 lac per month that's the point it doesn't matter how much he makes

  • @shivamelody3463
    @shivamelody3463 10 месяцев назад +88

    Studied whole subject topics in a single day from different videos of you sir🥹
    Hats off to your explanation❤️😍

    • @rohitkandula8493
      @rohitkandula8493 7 месяцев назад +3

      Same broo😍😍✨✨❤❤

    • @JSTANESJENSONURKCS
      @JSTANESJENSONURKCS 2 месяца назад

      thenn please buy his mug and contribute him money 👍👍👍👍

    • @zeyface6366
      @zeyface6366 13 дней назад

      Without him I wouldn’t have a chance of finishing the AI course I almost completely missed

  • @MPKiller545
    @MPKiller545 5 лет назад +234

    Learned from nothing 30 minutes before my exam. I've passed it because of this video. Thanks!

    • @AmeerHamza-yw7ui
      @AmeerHamza-yw7ui 3 года назад

      Hi

    • @ysandhya8990
      @ysandhya8990 3 года назад +1

      If i give one problem related to this , can you solve?

    • @segudivija8388
      @segudivija8388 2 года назад +13

      @@ysandhya8990 haha exactly we cant because he is explaining only concept not logic and pseudo code

    • @mahabirneogy7195
      @mahabirneogy7195 2 года назад +1

      what are you doing currently?

    • @mohammadfaisal3649
      @mohammadfaisal3649 2 года назад +3

      @@ysandhya8990 give me the problem ill solve it

  • @mikewal-ente3521
    @mikewal-ente3521 7 месяцев назад +23

    Greetings from germany! I was researching how to solve the knapsack problem and after hours of trying to understand the dynamic approach I came across your video explaining the branch and bound. Very clear and informative!

    • @JSTANESJENSONURKCS
      @JSTANESJENSONURKCS 2 месяца назад

      thenn please buy his mug and contribute him money 👍👍👍👍

  • @3shul103
    @3shul103 3 года назад +36

    saved my carrer #DAA ...... in a single flow completed all topics #one day batting with full marks thanks a lot sir

  • @parameshwaran8868
    @parameshwaran8868 4 месяца назад +4

    Theres just a small mistake in the formula he wrote. Its not ΣPiXi . Its just ΣPi for both formulas given the condition that the weight

    • @sidharthad72
      @sidharthad72 2 месяца назад

      It's actually the correct formula. You can also find it in Horowitz. That Xi is either 0 (include object) or 1(don't include object).

  • @letscode5367
    @letscode5367 6 лет назад +52

    Highly impressed by your teaching skills sir 💜

  • @user-js9xq1ps3s
    @user-js9xq1ps3s 4 года назад +2

    Very high teaching skills. Τα δικά μας τα στραβόξυλα στην Ελλάδα θα ήθελαν 300 διαφάνειες και 20 βιβλιογραφικές αναφορές για να εξειδικεύσουν τη γενικότητα και στο τέλος να μη καταλάβει κανένας χριστό και εκείνοι να νιώθουν σπουδαίοι που κανένας δεν κατάλαβε το τόσο υψηλού επιπέδου μάθημα.

  • @nikhilgodbole4425
    @nikhilgodbole4425 6 лет назад +4

    You have explained the method very nicely and clearly.

  • @vikrampareek8713
    @vikrampareek8713 5 лет назад +19

    very helpful for my exams. Thank you @Abdul Bari Sir

  • @jackiep9755
    @jackiep9755 3 месяца назад +1

    I am so very grateful to have found this channel. Very beautiful and clear explanations for these tricky concepts. Sending thanks from Seattle, WA.

    • @JSTANESJENSONURKCS
      @JSTANESJENSONURKCS 2 месяца назад +1

      if you are really grateful thenn please buy his mug and contribute him money 👍👍👍👍

  • @mark0504
    @mark0504 Год назад +16

    Thanks sir for the explaination. However, I am confused why in 0/1 knapsack problem we are considering fractional weight and profit?

  • @kavyaramamurthy9102
    @kavyaramamurthy9102 5 лет назад +8

    Sir, the way you teach is very nice and understandable.. I'm so glad I found you, and I'm passing in this subject only because of you❤ thank you so so much.

  • @Sameer-jv5vx
    @Sameer-jv5vx Год назад +2

    thanks a lot sir all the syllabus i have prepared for design and analysis of algorithms for my semester
    tmmrw i have semester and prepared everything in a great manner only bcoz you sir thanks a lot

  • @MuraliKrishna-ut7ir
    @MuraliKrishna-ut7ir Год назад +2

    And the first thing u have to check before starting the sum is that all the profits and weights given should be in non-decreasing order of their profits/weights ratio. If there u can do or else u should sort. It is not required while solving 0/1 knapsack in DP.
    And at the final your sol vector will be for the sorted set of elements kindly notice it and change it to normal given set of weights.

  • @tanmaypriyadarshi865
    @tanmaypriyadarshi865 6 лет назад +3

    Very well explained..... Perfect in every aspect....

  • @satang500
    @satang500 4 года назад +3

    thanks for the great video, i learned a new way to solve this problem, what's the time and space complexity to solve this using branch and bound?

  • @soself_learner412
    @soself_learner412 11 месяцев назад

    Hi, Sir. May I know if the weight capacity remains 1? Can I simply include and add on a fraction value (v/w) from the Item that has a bigger value? Or, based on this method, just find what items are required to choose s={1010} is enough?

  • @akhilkumar3077
    @akhilkumar3077 5 лет назад +4

    What if the cost value comes to be a fraction value? Should we round it off or continue with fraction?

  • @Emperor723
    @Emperor723 4 дня назад

    what are we comparing the upper bound (which was infinity in the beginning) with U or C in the nodes ?
    somewhere you are saying compare with U , and somewhere with C ?

  • @SaiKumar-zw9eh
    @SaiKumar-zw9eh 6 лет назад +5

    Sir at 9:30 when u r including 4th object from node 7, if the weight exceeds 'm' then should we skip the step of adding 4 like the similar way we did at 6th node?

  • @cmpunk1497
    @cmpunk1497 6 лет назад +6

    Thanks sir.. this ditto question appeared in my exam and got me 20 marks. :)

  • @mohdAbdulRahman20
    @mohdAbdulRahman20 4 месяца назад

    What an explanation sir 💯
    Easy way to understand lengthy problems
    I am very thankful to you

  • @c.danielpremkumar8495
    @c.danielpremkumar8495 6 лет назад +1

    If we have to choose the same object more than once, for optimization - should we multiply the profits and weights of that particular objects appropriately and consider it as a single node ?

  • @biswachat8521
    @biswachat8521 4 года назад +2

    @Abdul Bari In LC-BB, if there are 2 or more nodes with the same cost, which node should be picked up first for exploration?

    • @pascalfragnoud2846
      @pascalfragnoud2846 2 года назад

      It doesn't matter as they have the same cost. You can pick one randomly, or in the most convenient order for your algorithm (the one that comes first in your datastructure)

  • @Jatinder.thakur
    @Jatinder.thakur 5 лет назад +2

    M cleared with the concept. Thank u sir...keep posting such videos

  • @indumatiparida3400
    @indumatiparida3400 6 лет назад +2

    Thank you.so easy method to solve knapsack problem.

  • @sujitmohanty1
    @sujitmohanty1 8 месяцев назад

    Sir looks more like corporate big shot trainer. I am not sure but sir could definitely become one of the finest entreprenure in IT. Just a wish !

  • @c.danielpremkumar8495
    @c.danielpremkumar8495 6 лет назад +16

    What is the significance of taking the Upper Bound as INFINITY at the beginning ? Can't we instead take this value as ZERO since we are dealing NEGATIVE values ?

    • @sawoodshariff8287
      @sawoodshariff8287 5 лет назад +2

      u cannot take it as 0 initially because we deal upper bound as negative no so INitially infinity wil be source

    • @VasuGarg
      @VasuGarg 4 года назад +1

      @@sawoodshariff8287 it should be negative of infinity then only -32 can replace it.

  • @sergioaugustoangelini9326
    @sergioaugustoangelini9326 3 года назад +1

    Why is it that, no matter the object of the lecture, a random Indian guy is always gonna be there for me to solve my problems? God I love the internet, and India also

  • @payalk.4344
    @payalk.4344 5 лет назад +2

    Sir if possible kindly give algorithms for each kind of problem in BnB.Love your vidoes/

  • @samridhigupta1657
    @samridhigupta1657 3 года назад +1

    Could you please let me know that why branch and bound is used only for minimization problems?

  • @apporvaarya
    @apporvaarya 5 лет назад +1

    sir g you are the best..at least better than my nit professor :)

  • @aswathyprakash2566
    @aswathyprakash2566 4 года назад +2

    Awesome lecture sir..Thanks a lot ..

  • @Varshakumari-uz8uo
    @Varshakumari-uz8uo 4 года назад +4

    Sir, what to do if there is 4 object and after considering 2 object capacity of bag become 1 less than its capacity, Whether to take fraction of only 3rd obj or both 3rd and 4th.

  • @manideep_talampally
    @manideep_talampally 5 лет назад

    Sir ! U said that u'll change the -ve values to +ve at last ....where did u done that ?

  • @rohith_reddy
    @rohith_reddy 6 лет назад

    Sir, in knapsack problem we generally sort the values according to the profits
    and then start adding them to the sack what if we shouldn't consider the last one or something like that.

  • @Nikhil-qd9up
    @Nikhil-qd9up 3 года назад +12

    Whats the need of taking cost in fraction though we r considering 0/1 knapsack?

    • @thepriestofvaranasi
      @thepriestofvaranasi 3 года назад

      To calculate the upper bound. If you take the fractional cost, that would be the maximum you can accomodate. So it is the upper bound.

    • @thepriestofvaranasi
      @thepriestofvaranasi 3 года назад

      All those nodes whose cost will be greater than the upper bound would be obviously the part of incorrect soln so we can kill them.

  • @aditydud
    @aditydud 6 лет назад +2

    Sir it was an excellent explanation.

  • @SaiKumar-zw9eh
    @SaiKumar-zw9eh 6 лет назад +1

    sir, when you are initially taking the objects weight at 3:18 is there any precedence like taking the objects whose weight is less or it's taken in the order given in the question.

  • @2000danispy
    @2000danispy 3 года назад +1

    what is the complixity of the algorithm? I mean how much time would it take to find the optimal answer

  • @chundurusriharsha2402
    @chundurusriharsha2402 6 лет назад

    Sir,whether the weights should be in ascending order or it can be in any order,to solve the problem

  • @akashtakawale9074
    @akashtakawale9074 3 года назад

    Thank you so much Sir !! This is videos are really helpfull !🙏🙏

  • @prasanna2171
    @prasanna2171 29 дней назад

    Sir should we need sort them before starting the state space diagram

  • @priyalpareek12
    @priyalpareek12 6 лет назад +1

    Sir, how to solve this problem by FIFO branch and bound?

  • @pinakranjandas5770
    @pinakranjandas5770 Год назад

    sir is it necessary for 0/1 knapsack using branch and bound to be the weights in sorted order

  • @070-madihamanzoor2
    @070-madihamanzoor2 10 месяцев назад +3

    At 8:25 you were supposed to find if x3=0, as mentioned earlier you said that in order to calculate the upper bound we don't have to add the fractional part with the profit of rest of the elements but there you are adding the fractional part also. For me, it should have been U=-20 but you said it's U=-38. How?

  • @onaisteaches2659
    @onaisteaches2659 5 лет назад +4

    Mashallah well explained.I am your FAN, Sir.

  • @NikhilSKalme
    @NikhilSKalme Год назад +9

    Thank you sir for wonderful explanation!
    You have explained the Least Count Branch and Bound (LCBB)
    Can you please upload the video of FIFO for the same as you mentioned in the video somewhere?
    Please sir its a kind request !
    Thank you!

  • @rodrigopg463
    @rodrigopg463 5 лет назад +1

    Thank you theacher. Now I undestand and I believe that I`m able to go ahead with my code. I was wrong about my linear relaxation implementation code

    • @kailashuv3028
      @kailashuv3028 4 года назад

      Why we put the fraction 18/9?

    • @alexcosmic8110
      @alexcosmic8110 4 года назад

      @@kailashuv3028 It's price_of_item/weight-of_item. We are trying to evaluete losses.

    • @kailashuv3028
      @kailashuv3028 4 года назад

      @@alexcosmic8110 ok thank you👍👍👍

  • @jmoth827
    @jmoth827 5 лет назад

    how can we maximize the value while we have 2 constraints like weight and volume by using branch and bound? :(

  • @mayurgudi381
    @mayurgudi381 6 лет назад +1

    Always the objects are sorted in descending order of profit-weight ratio ?

  • @dsh35a
    @dsh35a 3 года назад

    can we take upper bound as positive integer
    ?

  • @sohamkudalkar2252
    @sohamkudalkar2252 6 лет назад +1

    Sir can u please explain the same knapsack problem using fifo branch and bound.

  • @shikshagarg5855
    @shikshagarg5855 6 лет назад

    Sir, I wanted the solution to this problem using FIFO branch and bound. Is it available ?

  • @sharmilasiram5438
    @sharmilasiram5438 2 года назад

    How are you deriving cost and upper bound functions?

  • @bavithakotlo3347
    @bavithakotlo3347 6 лет назад

    sir i'm getting confused with the LIFO method of this problem,can u explain me with that

  • @vasu6005
    @vasu6005 6 лет назад

    Sir pls make a video on nqueens and travelling salesman problem(backtracking) tooo.. #Urgent.. I like the way you teach.. Absolutely perfect!!

  • @DoSomethingProductive
    @DoSomethingProductive 6 лет назад +2

    Fantastic video my friend!

  • @amandureja3179
    @amandureja3179 5 лет назад +1

    Dear Sir, My question is that, when we are taking first node in 0/1 Knapsack Problem, why we are calculating the cost and upper values? Why they are not u= infinity and c=0 as like job sequencing with deadlines.

    • @chaoluncai4300
      @chaoluncai4300 Год назад

      we could do that, and technichly ur right about the initial settings

  • @Indumathishalewar
    @Indumathishalewar 2 года назад

    Sir while killing the nodes You compared upper bounds with cost ?

  • @tejasshaha6629
    @tejasshaha6629 5 лет назад +1

    Really ur doing great job....!

  • @arkamukherjee6385
    @arkamukherjee6385 5 лет назад

    sir why after the 3rd node we are taking from x3=0 why not from x3=1

  • @haritiger7330
    @haritiger7330 4 года назад +2

    On 01 knapsack problem using lc branch and bound please make one more video taking one more sum as an example

  • @haritiger7330
    @haritiger7330 4 года назад +2

    Sir please make one more video on least cost branch and bound taking one more sum as an example

  • @avinashsamarla3859
    @avinashsamarla3859 3 года назад +4

    Thank you sir superbly explained ❤️

  • @gv6980
    @gv6980 5 лет назад

    Why we are taking upper bound as the smaller value?

  • @MJgamer4U
    @MJgamer4U 3 года назад +1

    Can this be written for knapsack-backtracking?

  • @alyssagono7795
    @alyssagono7795 5 лет назад

    Why does we can only solve minimization problem in branch and bound?

  • @miriamsimonelli741
    @miriamsimonelli741 4 года назад

    Abdul, un giorno sarai nei ringraziamenti nella mia tesi di laurea!
    Abdul, one day you will certainly be on my acknowledgment in my thesis!

  • @jahnavimulakalapati5076
    @jahnavimulakalapati5076 5 лет назад +1

    sir for node 3 u=-27 is given in the text book for FIFO of the same problem.so how can i calculate it

  • @daniyajaweed5900
    @daniyajaweed5900 2 года назад +5

    SUCH A CLEAR EXPLAINATION!!! THANK YOU SO MUCH SIR! 😀

  • @sakshitantak9646
    @sakshitantak9646 4 года назад

    should we ideally sort the items in increasing/decreasing order of their profits/weights initially?

    • @shamuvishwakarma2285
      @shamuvishwakarma2285 4 года назад

      That is done in greedy method
      But as this is branch and bound we don't have to do that😊

  • @hiteshkumar3076
    @hiteshkumar3076 6 лет назад

    wt if the problem like this W=16
    item-1 -2-3-4
    weig-10 -7-8-4
    pro-100 -63-56-12
    how to calculate the upper bound here where there is an item of weight 4 is that can be include

  • @abhishekjain505
    @abhishekjain505 5 лет назад +6

    What if we need to take the fraction of more than 1 item, as in other 0/1 knapsack examples? This example deals with fraction of only 1 item.

    • @sakshitantak9646
      @sakshitantak9646 4 года назад

      exactly. do we sort the objects in increasing/decreasing order of profits/weights initially? That might help determine which object to pick right?

  • @gunjanmanore6285
    @gunjanmanore6285 6 лет назад +1

    Sir can you add knapsack using backtracking as early as possible...

  • @vikrampareek8713
    @vikrampareek8713 5 лет назад +1

    Sir can u upload FIFO branch and bound for 0/1 Knapsack?

  • @Sauravgpt34
    @Sauravgpt34 3 года назад +1

    Sir, what will be upper bound initially if we've M = 15 and up to 3rd element it is weights up to 10 and 4th element have weight 7 but 5th and 6th have 1 and 4 resp. Should we stop up to weight 10 or we can skip element 4th and move to 5th & 6th
    P = [10, 5, 15, 7, 6, 18, 3]
    W = [2, 3, 5, 7, 1, 4, 1]

  • @rachanamunot483
    @rachanamunot483 5 лет назад +5

    Respected sir, please can you also share the video for 0/1 knapsack using backtracking approach please...its urgently needed

  • @revanth7070
    @revanth7070 5 лет назад

    TQ SIR u have done lot of favour for us😍😍😍

  • @abhishekaa28498
    @abhishekaa28498 6 лет назад +17

    Please include 0/1 knapsack problem using backtracking

  • @duraicse2009
    @duraicse2009 6 лет назад +1

    Hi sir, could you please upload the lecture session for cutting a rod into pieces to make a profit in dynamic programming?

  • @aiswarya5848
    @aiswarya5848 5 лет назад

    Sir, you have taught 0/1 knapsack problem using branch and bound approach;but in ktu syllabus it comes under back tracking. Why so!?

  • @heythere4686
    @heythere4686 Год назад

    I have a doubt
    Both Fifo branch bound and least cost branch bound the same thing?

  • @madhuballa4118
    @madhuballa4118 5 лет назад

    Can i have knapsack problem using FIFO BB

  • @anybodycanlarn
    @anybodycanlarn 6 лет назад +1

    Sir when we are not including 3rd node then upper bound should be -20 instead of -38...…?
    Is i am right sir?

  • @pns_news
    @pns_news 4 года назад +2

    Sir your appearance is almost like my dad and your way of teaching is also almost just like him and I am habbitual of his way of teaching do I feel the same thanks ☺

  • @niharikagurjar1361
    @niharikagurjar1361 6 лет назад +2

    Sir can you explain knapsack using backtracking..?

  • @revanthjanaswamy5064
    @revanthjanaswamy5064 6 лет назад +1

    Sir I'm getting confused with FIFO branch and bound method of this problem. Can u please help me with that

  • @ilovemusic465
    @ilovemusic465 5 лет назад +1

    Sir plz upload the same using fifo and lifo branch and bound
    And
    Lower bound theory. Plz sir.

  • @erickgomez7775
    @erickgomez7775 Год назад

    I'm a time traveler from the year 3000. I came to this era to watch this video. In the future someone spilled coffee on the youtube server and this video was lost for good. Thank you, Sir. Now I con back to my time and continue packing for my trip to Jupyter.

  • @pvmraghunandanpotti7539
    @pvmraghunandanpotti7539 6 лет назад

    What if Profit = 1 (Becomes subset sum problem). Is it wise to use this as solution? The issue i am trying to solve is subset problem with float values rather than integers

    • @pvmraghunandanpotti7539
      @pvmraghunandanpotti7539 6 лет назад

      I tried with backtracking but with list of around 500 elements, finding is taking long time although memory is optimized. Any other better approach to handle list of 500 float values?

    • @pvmraghunandanpotti7539
      @pvmraghunandanpotti7539 6 лет назад

      And the input i am trying is where match is not possible for the given sum in the input list of elements.

  • @justinlee6075
    @justinlee6075 5 лет назад +4

    I was trying this algorithm with different values: 10, 10, 1, 36 and keeping the weights the same. I believe the correct answer is 56. But when I follow this algorithm, I get 46. The way I've been selecting the next node is through the least cost of the nodes, NOT the least upper bound of the nodes. If anybody tries this and gets 46, let me know. Or if I did this wrong in any way, let me know.

    • @kolonkignome2696
      @kolonkignome2696 2 года назад +2

      I think that input should be sorted by profit/weight ratio, decreasingly

    • @chaoluncai4300
      @chaoluncai4300 Год назад

      @@kolonkignome2696 +1, also prefers smaller profit or weight for breaking ties during sorting.

  • @nazmulhaquenahin
    @nazmulhaquenahin 5 лет назад

    love from Bangladesh..Sir

  • @durgaprasadpatlolla8995
    @durgaprasadpatlolla8995 6 лет назад

    Sir plzz include 15 puzzle problem using branch and bound also

  • @sailigarad615
    @sailigarad615 5 лет назад

    Sir... i want the solution of 0/1 knapsack problem with FIFO

  • @rakeshaahir8657
    @rakeshaahir8657 5 лет назад

    Sir, since it is 0/1 Knapsack Problem , then why we are taking fraction of profit over here?

  • @YH-cd7xh
    @YH-cd7xh 4 года назад +7

    I do not understand how the upper bound and cost come

  • @manojmuraboina6834
    @manojmuraboina6834 6 лет назад +1

    Can you please explain the same type of problem where profits=weights.

  • @diptoacharjee7538
    @diptoacharjee7538 11 месяцев назад

    What will be the worst case time complexity of this approach??