Knapsack Problem Explained - Algorithms in Python

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ม.ค. 2025

ความคิดเห็น • 16

  • @golmatol6537
    @golmatol6537 8 หลายเดือนก่อน +4

    Wish you had drawn out an actual table (perhaps with just 3-4 items) and run through it manually to show the values are being updated. Will need to watch some other knapsack related video now to really understand that last algorithm.

    • @pitaeata8493
      @pitaeata8493 8 หลายเดือนก่อน

      i got lost on the last one too, still interesting.

  • @dipeshsamrawat7957
    @dipeshsamrawat7957 8 หลายเดือนก่อน

    Broh, may I please know which software do you use to create your very good Thumbnails?

  • @Dyanosis
    @Dyanosis 8 หลายเดือนก่อน

    Your dynamic algo is definitely not efficient if you're looping over i and w and not just starting from 1 instead of 0. Why start from a number and be forced to initialized and ignore it if you could start from a number that matters? Also, seems a little weird that you're loops from 0 to 15 but looking at the previous item and previous DP. Wouldn't it make just as much sense to loop from 0 to 14 and get the same result?

  • @MovieClips14359
    @MovieClips14359 8 หลายเดือนก่อน +2

    Build ai agent automation seo analyzer

  • @y2ksw1
    @y2ksw1 8 หลายเดือนก่อน +1

    It's actually pretty easy to solve: search for the item with the largest value and smallest weight. Then repeat until the sack is filled.
    This is the method I have used at industrial scale and it performs outstandingly. Performance is the highest value in the industry, because time is money 😊

    • @rakotoarilantonirinadesire4110
      @rakotoarilantonirinadesire4110 7 หลายเดือนก่อน

      I think he has done it with the second solution. He was talking about ratio between value and weight.

    • @y2ksw1
      @y2ksw1 7 หลายเดือนก่อน

      @@rakotoarilantonirinadesire4110 He computed a value and ordered it accordingly to it. However, on large data fields, division is more expensive than multiplication, and sorting prohibitive, if not impossible. Imagine a large user database and the intent to collect a number of members with similar attributes. With my method, I do a record scan and remember simply the records, in a small array, which match the criteria, over the whole set of records. By the time I would make the division or multiplication, I have the values already placed, and by the time the second iteration of a sorting algorithm would start, I have scanned all data.

    • @gsscala
      @gsscala 6 หลายเดือนก่อน +1

      Your solution is "good enough" but doesn't return the actual best combination. There's no simple greedy solution to this problem.

    • @y2ksw1
      @y2ksw1 6 หลายเดือนก่อน

      @@gsscala The industry wants the fastest and still best solution for the problem. In case of doubt, speed prevails.

  • @CodingDevelopers
    @CodingDevelopers 8 หลายเดือนก่อน

    Excellent video it helped me thx a lot. I am your fan so please pin me.

  • @philtoa334
    @philtoa334 8 หลายเดือนก่อน

    Thx_.

  • @coopernik
    @coopernik 8 หลายเดือนก่อน

    It’s just Tetris. Debate

  • @mrvincefox
    @mrvincefox 8 หลายเดือนก่อน

    Argh that damn keyboard.
    CLACK CLACK BASH BASH CLACK CLACK