0-1 Knapsack Problem - Dynamic Programming

  Рет қаралды 57,643

CSBreakdown

CSBreakdown

9 жыл бұрын

Discussion of the 0-1 (Integer) Knapsack, a known NPC problem. Through use of dynamic programming we are able to calculate an optimal solution in pseudo-polynomial time.

Пікірлер: 31
@christopherschoeder6781
@christopherschoeder6781 7 жыл бұрын
for future videos, I would recommend having a "draw screen" or having a cursor to show which value you're showing. Otherwise rambling off numbers for someone who's trying to understand both the concept and what the publisher is saying can be difficult to interpret
@MsClrs
@MsClrs 7 жыл бұрын
The best video for the knapsack problem. Great work!
@yasmeennaseer
@yasmeennaseer 7 жыл бұрын
Truly understood dynamic programming for knapsack for the first time in my life!!
@blindprogrammer
@blindprogrammer 8 жыл бұрын
thanks, every good video! if possible, can you please tell me which software did you use to build this video?
@christiansakai
@christiansakai 7 жыл бұрын
So you guys are students who teach! amazing!! very very good videos!
@heisenburger311
@heisenburger311 6 жыл бұрын
Watching it double times makes me understand much more.
@SKPSonaipatty
@SKPSonaipatty 6 жыл бұрын
good work, thanks a lot.
@pauliewalnuts6734
@pauliewalnuts6734 7 жыл бұрын
great video thanks champ :)
@ianbolfa
@ianbolfa 7 жыл бұрын
Thanks a lot!!!
@debarkasengupta5351
@debarkasengupta5351 7 жыл бұрын
The optimal substructure description part is unclear.
@huxi8070
@huxi8070 7 жыл бұрын
Hi, I have problems to understand which values do you take into account when calculating the Cell [2,6]. Could you please explain? I think I dont understand the variables. If "v" is the value, what is "c"? Is "M" the Max value? Is wi the column index? Thanks
@megmeyers3432
@megmeyers3432 7 жыл бұрын
Zuzana Dee I agree. This is unclear.
@shawnscientifica6689
@shawnscientifica6689 7 жыл бұрын
Meg Meyers So what's going on here is you make a matrix. The rows are the item number. You start with 0 (no item at all) and go up to how many items you have. In this case we have 4 items so we go from 0-4. Ok. Now we need columbs.The columbs are starting from a smaller weight and going up to our Max weight. Why? Well, if we pick (imagine you need to steal jewels from a tomb but can only carry so much weight) if we pickup all the most valuable jewels and don't go over for the smaller weight then we can make a mental note of this for when we get stronger and can pick up more jewels. At that point you can remember that back when you weren't so strong you could get $X of valuables. With that information you can decide if it makes sense to put down an item and pick up a heavier item (where you'll get more money) or not even bother (all the other stuff is too heavy and replacing one of the jewels you had before makes you leave with less $$$) so basically you're using it as a stepping stone. Ok, now you go up in the columbs up to the real maximum weight you can carry, now you will be able to make the best decision based on all those past mental notes of less weight problems. The answer is the one in the last row and column. Hope this helps.
@sanjaykg10
@sanjaykg10 7 жыл бұрын
can u please tell me how to solve 0/1 Knapsack Problem using merge and purge method
@dmitriimarkov7067
@dmitriimarkov7067 3 жыл бұрын
Would be better if you had more animations. For example, when you say about particular cell in the table, color it so it can be distinctive from other cells.
@sid9860
@sid9860 8 жыл бұрын
where is fractional knapsack problem video :( ???
@x87-64
@x87-64 4 жыл бұрын
Just greedily take the ones which have largest value/weight ratio.
@Mike-ci5io
@Mike-ci5io 8 жыл бұрын
- The max=13 in the beginning should be described as the max weight the bag can handle not "value" - Doesn't the greedy approach pick items 4 and 2 (has the next big ratio) instead of 4 and 1. w4 + w2 < 13?
@jack_galt
@jack_galt 8 жыл бұрын
+Intelli Vester 2's ratio is 4/6 = 2/3, as opposed to 1's ratio of 5/5 = 1, so 1 is taken.
@flyingSapo
@flyingSapo 8 жыл бұрын
Why is it "pseudo-polynomial time"? That was never explained...
@CSBreakdown
@CSBreakdown 8 жыл бұрын
+yoDood Hi! Thanks for watching our video. We have a separate video dedicated to the explanation of Polynomial time algorithms vs. Pseudo-Polynomial algorithms. You can check it out here: kzbin.info/www/bejne/p3fIc3eeYriil6M
@flyingSapo
@flyingSapo 8 жыл бұрын
Thanks for the response! Keep up the great work! Your videos really helped me understand better.
@MsClrs
@MsClrs 7 жыл бұрын
I have a question, position (2,4 ) should be 4. Right?
@shawnscientifica6689
@shawnscientifica6689 7 жыл бұрын
MsClrs Well let's see. So we are looking at item #2 which is a Gem that weighs 6lbs and is worth $4. Since the columns are the weight (we start from smaller weights and make note of the maximum $$$ we can get at that weight for deciding when we can carry more stuff) We realize at row 2 (looking at items 1-2) and column 4 (when we can only carry 4 lbs) we see we can't take item #2 since it's 6lbs. So we look at item #1 which is 5lbs. So we are too weak to carry anything so we leave the mystical tomb with nothing but a story (0$)
@MsClrs
@MsClrs 7 жыл бұрын
Shawn Scientifica super!! Thanks a ton 😊
@jiap2uw
@jiap2uw 7 жыл бұрын
Is c[i][M] = c[i-1][M] if wi < M instead of wi > M ???????????????
@shabyparveen1649
@shabyparveen1649 2 жыл бұрын
3rd will be applied.
@emirbalic8800
@emirbalic8800 8 жыл бұрын
very good. clear and confident. thanks
@saffaura
@saffaura 4 жыл бұрын
I had headphones in... And the volume turned up... And my ears are bleeding after that intro. Major yikes.
@anuraggupta8197
@anuraggupta8197 6 жыл бұрын
Dued, our intro suck. My ears are bleeding
Change Making Problem - Dynamic Programming
13:24
CSBreakdown
Рет қаралды 65 М.
0/1 Knapsack problem | Dynamic Programming
13:29
WilliamFiset
Рет қаралды 142 М.
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 74 МЛН
OMG😳 #tiktok #shorts #potapova_blog
00:58
Potapova_blog
Рет қаралды 3,8 МЛН
Vivaan  Tanya once again pranked Papa 🤣😇🤣
00:10
seema lamba
Рет қаралды 25 МЛН
She ruined my dominos! 😭 Cool train tool helps me #gadget
00:40
Go Gizmo!
Рет қаралды 60 МЛН
Función Racional Verdadero Falso
16:28
Ricardo Jara
Рет қаралды 8
The 0/1 Knapsack Problem (Demystifying Dynamic Programming)
20:30
Back To Back SWE
Рет қаралды 202 М.
Recitation 21: Dynamic Programming: Knapsack Problem
1:09:12
MIT OpenCourseWare
Рет қаралды 199 М.
Dynamic Programming - 0/1 Knapsack Problem Tutorial
46:18
freeCodeCamp.org
Рет қаралды 32 М.
4.5 0/1 Knapsack - Two Methods - Dynamic Programming
28:24
Abdul Bari
Рет қаралды 2,7 МЛН
0-1 Knapsack problem - Inside code
10:54
Inside code
Рет қаралды 8 М.
Matrix Chain Multiplication - Dynamic Programming
31:01
CSBreakdown
Рет қаралды 226 М.
0/1 knapsack problem-Dynamic Programming | Data structures and algorithms
27:31
Jenny's Lectures CS IT
Рет қаралды 1,1 МЛН
01 Knapsack using Recursion | Building Intuition
18:38
Techdose
Рет қаралды 51 М.
0-1 Knapsack Problem (Dynamic Programming)
9:20
CS Dojo
Рет қаралды 478 М.
Can You Draw A PERFECTLY Dotted Line?
00:55
Stokes Twins
Рет қаралды 74 МЛН