Recitation 21: Dynamic Programming: Knapsack Problem

Поділитися
Вставка
  • Опубліковано 2 лют 2025

КОМЕНТАРІ • 94

  • @aleksagordic9593
    @aleksagordic9593 7 років тому +102

    0:20 - 26:30 Knapsack solved using graphs
    26:30 - 48:25 Knapsack solved using DP
    48:25 - 1:00:00 pseudo-polynomial runtime
    1:00:00 - 1:09:11 shows why is Dijkstra not pseudo-polynomial but polynomial. (also counting sort is pseudo-polynomial)

    • @kashifnehal8508
      @kashifnehal8508 5 років тому +1

      thanks buddy

    • @patmaloyan620
      @patmaloyan620 4 роки тому +1

      Just wanna say i have been using ur notes the whole course, and helped save a lot of time for me. THANK YOU!

    • @expansivegymnast1020
      @expansivegymnast1020 2 роки тому

      You a real one

  • @mikealexcai
    @mikealexcai 11 років тому +62

    DP method starts at 0:26:04

  • @Adrian-xe2sn
    @Adrian-xe2sn 2 роки тому +5

    Every professors famous words. "I promise to answer any emails over weekend". Responds to none

  • @wihlke
    @wihlke 11 років тому +21

    Opposed to what others seem to feel about this, I think it was very easy to follow. Great lecture!

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

      @@mariasandru7 where are you working now, just curious

  • @gerarddeepak4822
    @gerarddeepak4822 10 років тому +21

    What an awesome lecture.Way to go Professor

  • @mohamednofal5256
    @mohamednofal5256 6 років тому +6

    58:19
    "Once you said it. it's a constant" he made my day lamo

  • @janmichaelaustria620
    @janmichaelaustria620 3 роки тому +5

    I'm really opposed to jumping into the iterative bottom up dp solution when it comes to dynamic programming. It makes more sense to solve the problem top down recursively first, then just translate to bottom up dp.

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

    I think I am missing something. I cannot understand why the instructor says 'we can connect source to each layer at the start and that this corresponds to the amount of weight we waste' (20:53). Nor do I see the need to connect to a single destination. I don't see where either of these are required to build a DAG. Why make the graph more complicated?

  • @AhmadNasikun
    @AhmadNasikun 10 років тому +4

    Nice stuff..
    a little problem with the subtitle/CC though.. on 1:07:56 (and some points later on as well) the sub-title guy wrote 'Rating sort' when it's supposed to be 'Radix sort'..

    • @mitocw
      @mitocw  10 років тому +4

      Thanks for your note! The subtitles have been fixed and should update shortly on UA-cam.

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

      ***** can you please tell that why do we use bubble sort in knapsack although it has more time complexity

    • @mathemagiks
      @mathemagiks 8 років тому +5

      +Aayush Kumar We never use bubble sort.

  • @AlexMerritt0000
    @AlexMerritt0000 8 років тому +2

    @48:40 which problems is he referring to? Problem set 7? There seem to be only two problems in that set.

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

      I'm wondering the same thing. Let me know if you found out what problem he is referring to

    • @beingAlive
      @beingAlive 4 роки тому +1

      He's referring to Subset Sum and K-Sum problems given in recitation notes of this recitation.

  • @abacusyou
    @abacusyou 3 роки тому +2

    I still don't get the reoccurrence relation. It seems like it should be i-1

  • @banachspace1120
    @banachspace1120 4 роки тому +1

    A good video, it helped me a lot to understand the reading, thanks!!

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

    @14:13 I'm confused by how the edge weights are calculated. Perhaps I'm missing some prerequisite knowledge.

    • @entropyfrances9527
      @entropyfrances9527 3 роки тому +1

      if you select current item, the edge weight will be the value of current item, otherwise zero.

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

      @@entropyfrances9527 Thanks so much! I really appreciate your help.

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

    DP was not completely obvious after some workout I could understand how it works
    thanks for the post

  • @jeyfus
    @jeyfus 10 років тому +6

    That silence ^^ ( 26:37 )

  • @kazama81
    @kazama81 5 років тому +1

    Sorry for the ignorance, but is the code/implementation of the knapsack problem absent, because it is obvious after lecturer's theoretical explanation?

    • @JohnDoe-sp3dc
      @JohnDoe-sp3dc Рік тому

      It's left as an exercise for the viewer. In all seriousness I think this class is about proving that this algorithm can find the optimal set of items in some O() n time not necessarily implementing the algorithm.

  • @ravindrabhatt
    @ravindrabhatt 11 років тому +2

    How is the weight -10? I am not sure how to compute the weight could you some one explain please?

    • @nikjohnman4752
      @nikjohnman4752 11 років тому +2

      that is not weight. it is value.

    • @mariasandru7
      @mariasandru7 7 років тому +3

      Hi, Ravi! He does the reverse of the Shortest path problem. Shortest path problem is the problem of finding a path between two vertices (or nodes) in a graph such that the sum of the weights of its constituent edges is minimized. But do we want the cost to be minimized? Of course not, we want to take objects as expensive as possible. We want the cost to be maximized. So instead of saying 10, we are saying -10 to inverse the aim of the Shortest path problem.

  • @janmichaelaustria620
    @janmichaelaustria620 3 роки тому +2

    anyone keep a counter on the number of times Victor has broken chalk? LOL

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

    Two confusion ..can any1 please explain clearly:
    1. 28:36 to 28:38 please explain why (items ≥ i) ? ................... I thought it should be (0 ≤ items ≤ i)
    2. 31:06 to 31:14 why dp[i+1][j-Si] ................................................ I thought it should be dp[i-1][j-Si]

    • @mariasandru7
      @mariasandru7 7 років тому +2

      With the second thing, you would be right if we had done it with prefixes, instead, he used suffixes. Ok...let me make myself clearer, you are right somehow, it is about recursion and you can do recursion only by knowing the precedent term. He is doing exactly that, but he fills the table backwards, where the i+1 is before the i element.

  • @rishavthakur9673
    @rishavthakur9673 5 років тому +2

    At 26:50 waiting for answers, he had his finger crossed :).

  • @Knot2goodAtIt
    @Knot2goodAtIt 10 років тому +4

    I pretty much got lost after he wrote the recursion of the DP....I have no idea how they filled that table in....

    • @mariasandru7
      @mariasandru7 7 років тому +4

      Just play that part 3 times or more, and you will eventually get it. That is how I did it. The key is the thing with suffixes.

    • @mohamednofal5256
      @mohamednofal5256 6 років тому +1

      its hard anyway. and i haven't seen anyone explains it better.

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

    Thanks, this helped me a lot

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

    my confusion is the decision of the nodes in the graph. was it by trial and error? Once you know the nodes, the sp graph problem and dp is trivial. Decision for graph nodes and dp sub problems is crucial

  • @hdching
    @hdching 2 роки тому

    Can we take multiple of the same item?

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

    dude is a genius but his hand writing sucks.

    • @csl1384
      @csl1384 5 років тому +3

      You don't need to be a genius to read it though

    • @troymcdivitt7818
      @troymcdivitt7818 4 роки тому +1

      @@csl1384 I can't read it so I am not a genius?

    • @abdolvakilfazli2488
      @abdolvakilfazli2488 4 роки тому +2

      so is your dictation: handwriting

  • @yangzhang2303
    @yangzhang2303 7 років тому +2

    nice shirt. it's both a graphic Chinese version dragon and Chinese calligraphy dragon 龍。

  • @sonijha1480
    @sonijha1480 7 років тому +4

    he is so cute and lecture was also good😍

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

    What series is this? What's the difference between this one and the one Erik did?

  • @landonova
    @landonova Рік тому

    item 1: does it fit? great! what's its value? noted....item 2: does it fit? great! what's its value? noted. is there any more space? yes! how much space? noted. so and so on. just store data in memory. and do that over and over. memory and resources are your constraints.

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

    how does he get O(V+E)

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

      +Fred Big Which sorting path did he use? dijkstra algorithm?

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

      Sorting an acyclic directed graph can be done in O(V+E) using a topological sort.

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

      BFS and DFS is also O(V+E) I believe.

  • @Jkauppa
    @Jkauppa 2 роки тому

    why are you solving traveling salesman

    • @Jkauppa
      @Jkauppa 2 роки тому

      godless need teachers for themselves, in vain, like you have to earn something

  • @Knot2goodAtIt
    @Knot2goodAtIt 10 років тому +4

    lol i get so mad when the students start talking over him....then I realize that its just a real lecture that's been recorded -_-

  • @study7691
    @study7691 4 роки тому +2

    This cameraman and his zooming in ruins everything! Very good explanation though. Thanks!

    • @joeystechpluscode
      @joeystechpluscode 4 роки тому

      hey, you want to check a new channel which explains you every dynamic programming in detail then here's Joey'sTech for you, check it out -> ua-cam.com/channels/lZqy__jsIj_6RpuoJXPLjw.html

    • @hil449
      @hil449 3 роки тому +1

      @@joeystechpluscode nice channel btw

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

      @@hil449 Thanks

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

    Awesome 😍

  • @aravindthangavelyou
    @aravindthangavelyou 8 років тому +2

    super dude

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

    Btw. I forgett to enwrite for the exam so I have to re-do another semester due to me missing formal paper stuff. I hate me

  • @shradhyeshrestha298
    @shradhyeshrestha298 4 роки тому

    how the run time became in order of n times 2 power b in pseudo-polynomial runtime??

    • @joeystechpluscode
      @joeystechpluscode 4 роки тому

      hey, you want to check a new channel which explains you every dynamic programming in detail then here's Joey'sTech for you, check it out -> ua-cam.com/channels/lZqy__jsIj_6RpuoJXPLjw.html

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

      because its not really polynomial. The run time is O(n*S) but if you change the word size then S grows exponentially

  • @oliverbeck6839
    @oliverbeck6839 4 роки тому

    Why are the students constantly laughing ? I feel like it's kinda of rude they are talking without raising their hands and giggling a lot ...

  • @violiotte
    @violiotte Рік тому

    This guy is so handsome. I wonder how he looks like now 🤔

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

    cool

  • @o0tamu
    @o0tamu 11 років тому

    what a babe

  • @lkez2
    @lkez2 8 років тому +5

    Ugh , he has really terrible writing. Hard to follow

  • @amirhosseinsadeghi3776
    @amirhosseinsadeghi3776 9 днів тому

    Handwriting is awful

  • @vermoidvermoid7124
    @vermoidvermoid7124 7 років тому +4

    Worst lecture on the knapsacks problem. There are many other smaller videos that do a better job. He got 1 hour on this problem and this is the output. Pretty bad.

    • @mohamednofal5256
      @mohamednofal5256 6 років тому +8

      he has solved it with more than one method the point is not to solve this problem in particular. its about the methods being used

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

      Remember this is a recitation and not a lecture.

    • @hil449
      @hil449 3 роки тому +1

      this was one of the best videos about this problem i've found. Not only he solved w/ 2 methods but he showed its pseudo-polynomial which alot of channels dont even talk about

  • @englosluck6860
    @englosluck6860 10 років тому +2

    horrible board writing

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

    he is a weasly

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

    To be honest, sloppy handwriting, heavy accent, all these do not make the lecture effective to the students. I find Erik's sessions are more easy to follow.

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

      +KingsEagle the handwriting just goes to show you he grew up in a different culture. Perfectly readable for me (from Germany) since I'm used to it - I would even say it's a very good handwriting (at least on a chalkboard). Just needs some time to get used to.

    • @mabehal-zuqyadeek8593
      @mabehal-zuqyadeek8593 9 років тому +14

      +KingsEagle I take that you've either never been to college or were never in any science or mathematics intensive classes in college.
      This guy is great and not even 1/50th of what I've seen in college and graduate school.

    • @DarkLordAli95
      @DarkLordAli95 7 років тому +14

      "Heavy accent" are you fucking kidding me???!!!
      that's nowhere near a "heavy" accent. you need to start going out and interact with foreigners, and people in general.
      Most of my CS profs have an accent that's thicker than this, along with bad grammar, and all of them except one (which is why im here) are great at delivering concepts and ideas.
      it would be really amusing to see you being dumped in Germany and having to interact with people that have a truly thick german accent.

    • @edenender
      @edenender 2 роки тому

      Hé was in my classroom in high school back in Romania on one of the best schools in the country in informatics and science. Victor Costan was probably one of the best from our classroom and with high sensé of humour and à great pal.

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

    your students need to pay attention! theyre asking useless questions!