4.5.1 0/1 Knapsack Problem (Program) - Dynamic Programming

preview_player
Показать описание
0/1 Knapsack Problem explained using Program

Courses on Udemy
================
Java Programming

Data Structures using C and C++

C++ Programming
Рекомендации по теме
Комментарии
Автор

You are an excellent teacher, sir. Your effort is much appreciated.

willjay
Автор

I hope this AMAZING channel reachs millions of subscribers, THANKS, sirm you are awesome 🥊

aaronaaronaaron
Автор

Taught very clearly!
(Perhaps a little mistake at 15:26 ? Reducing i-- before accessing J for weight reduction would seems wrong ?)
Thanks for this brilliant teaching sir

johnc
Автор

there is small error in the code at 15:11 first we have to write j=j-wt[i] then i=i-1;

sampreethrv
Автор

Correction :
cout<<K[n][m];
and Sir, Thank uh for this lovely explanation.

rahulchawla
Автор

I have now understood the meaning of the universe, the key to everything... but I cannot explain it (or give it) to you. You have to find it by yourself...

mrkyledescoudres
Автор

Breakdown of the formula:
⭐K: DP table which stores values of subproblems

⭐K[i, w]: Maximum profit by considering the first 'i' elements in a bag of weight 'w'

⭐p[i]+ K[i-1, w-wt[i]]: Case when the current object is included(~1) 'p[i]' and the remaining part of the bag 'w-wt[i]' must be filled with the maximum profit possible (stored at 'i-1')

⭐K[i-1, w]: Case when the current object is not included(~0) and the bag with current weight 'w' must be filled with the maximum profit possible (stored at 'i-1')

(~ Hence the name 0/1 knapsack problem)

sumant
Автор

Awesome content, by far the most understandable and easy to understand. I aspire to be you when explaining a difficult topic.

flexerfadrigalan
Автор

Best explanation about knapsack algorithm implementation on youtube. Thanks a lot!

mauriciocmarinho
Автор

Sr, I have no words for appreciation of your way of teaching. I can't compare it with that of any other course faculties or youtubers. Its Unique ! I am following your course also for dsa from Udemy, i have successfully completed it and it happened first time with me that I am almost 90-95% satisfied with a purchased course and that is also at easily affordable cost. Thankyou So Much for your efforts for us, Sr. I want to pay Respect to you by heart !🙏

-avnee
Автор

No words to describe how excellent your teaching is .

surajsuryawanshi
Автор

you are just amazing sir as i have problem in english but i understood you explanation you are simply great sir
thank you so much sir
🙏🙏🙏🙏

SaraswatiShelke
Автор

future viewers, some things to note!!
it's important for p[0] = wt[0] = 0 to exist. in the video, p and wt already have 0 at the start. this makes the table's first row and first column filled with 0.

your implementation may need to change if your table's doesn't have that initial condition. you might see `p[i-1]` and `wt[i-1]` in other implementations, this is because the "p" and "wt" usually don't have 0 instantiated thus you shift everything over by 1 to fit the first row filled with 0 (therefore requiring you to do i-1 to index correctly).

phantomvisual
Автор

I can't belive how talented you are

VanjeAv
Автор

This code is stuck in my mind from the way you explained thanks for taking so much efforts for us God bless uhh 🙏

stutisflairs
Автор

Thhank you teacher for this lesson and the previous one concrning the knapsack problem it is really well understood and well explained

ntaange-junior
Автор

on 15:02
It should be
cout<<i<<"=1"; j=j-wt[i]; i--;
not
cout<<i<<"=1"; i--; j=j-wt[i];

Sourav
Автор

Thank you sir, been following your videos for DAA and they're very helpful! I had a doubt, I'm not able to understand why 0/1 knapsack has exponential complexity, looking at the code it seems the program has O(n*m) complexity..

shk
Автор

Sir, you are an excellent teacher. Thanks a lot...

raghavddps
Автор

what an explaination brother keep it up!
keep going bro

MANUCRIXZ