Matrix Chain Multiplication | Dynamic Programming

Поделиться
HTML-код
  • Опубликовано: 8 сен 2024
  • In this video, I will show you how to fill in the table for the Matrix Chain Multiplication problem. It uses Dynamic Programming. Matrix Chain Multiplication will allow you to multiply matrices together in a way such that the cost is minimum. Matrix chain multiplication is an optimization problem concerning the most efficient way to multiply a given sequence of matrices. The problem is not actually to perform the multiplications, but merely to decide the sequence of the matrix multiplications involved. The problem may be solved using dynamic programming. On the other hand, Dynamic programming is both a mathematical optimization method and a computer programming method. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, from aerospace engineering to economics. Dynamic Problems come up a lot in computer science and programming interviews.

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

  • @colemanroy
    @colemanroy 8 месяцев назад +11

    Exactly what I wanted, super straight forward and very well explained. Legend!

    • @QuocDatPhung
      @QuocDatPhung  8 месяцев назад +2

      Thanks Colemanroy! I'm glad it helps! Also don't forget to share with others! You can find the rest of my Algorithms videos in this playlist: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @nichilus806
    @nichilus806 Год назад +5

    Great explanation/example. Brief but well done. My classmates and I thank you!!

    • @QuocDatPhung
      @QuocDatPhung  Год назад +2

      Thanks Nichilus! Please kindly subscribe, it means so much to me! You can also find the rest of my Algorithms videos in this playlist: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @net.navigator
    @net.navigator 11 дней назад +1

    the legend. thx man

    • @QuocDatPhung
      @QuocDatPhung  5 дней назад +2

      Thanks Net Navigator! Please kindly share with your friends and subscribe to support me (it means a lot) ~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

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

    Simple and Clear explanation... thank you. Gr8 video

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

      Thank you Shivasutube! Don't forget to share with your classmates and kindly subscribe ~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

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

    i da bestt mann
    you cleared the doubt which other videos didn't

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

      Haha thank you! Don't forget to share with your classmates and kindly subscribe ~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @r.krisnamoorthir.k4622
    @r.krisnamoorthir.k4622 3 месяца назад +2

    Thank you so much sir,

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

      You're welcome!! Please share with your classmates to help them in this course and also kindly subscribe ~ you can find all of my Computer Science videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

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

    Great explanation, quick too

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

      Thank you Spenter!! I'm really glad you enjoyed my video! I would really appreciate if you could share with your classmates or kindly subscribe ~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @purifynature8479
    @purifynature8479 Год назад +1

    Thank you. This really helped me.

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

    thank you or this, by the last 1,4 I did it my self

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

      You're welcome iTube! Please kindly share and subscribe~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @lalith_kumar_akhila2411
    @lalith_kumar_akhila2411 Год назад +2

    Saved my time 🎉 Appreciate it

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

      You're very welcome LalithKumar! Please kindly subscribe, it means a lot! Also, you can find the rest of my Data Structures and Algorithms videos here: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

    • @lalith_kumar_akhila2411
      @lalith_kumar_akhila2411 Год назад +1

      @@QuocDatPhung sure 😊

    • @QuocDatPhung
      @QuocDatPhung  Год назад +2

      @@lalith_kumar_akhila2411 Oh I forgot to mention, if you are taking Dynamic Programming (Analysis of Algorithms) which is a different course from Data Structures, here is the playlist for that course: ruclips.net/p/PLeTO6OT3-FKl-_EkIipoUmctPhvqiVPtY

    • @lalith_kumar_akhila2411
      @lalith_kumar_akhila2411 Год назад +1

      @@QuocDatPhung Thank you, I'll go through it

  • @vijei8963
    @vijei8963 9 месяцев назад +1

    Thank you so much!

    • @QuocDatPhung
      @QuocDatPhung  9 месяцев назад +1

      Thanks Vijei! You can find all of my Algorithms videos in this playlist: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @gadithya4447
    @gadithya4447 Месяц назад +1

    could u share what tool you are using?

    • @QuocDatPhung
      @QuocDatPhung  Месяц назад +2

      Hi Gadithya! I use wacom tablet ctl 490 to write. I also use the Sketchbook app, OBS to record the screen, and Shotcut for editing. I hope that helps! Please kindly subscribe and share my videos it means a lot!

  • @soadscars4527
    @soadscars4527 8 месяцев назад +1

    Thank You

    • @QuocDatPhung
      @QuocDatPhung  8 месяцев назад +1

      You're welcome! Please kindly subscribe! As well, you can find all of my Algorithms videos in this playlist: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @marcugusan8222
    @marcugusan8222 Год назад +6

    👍

    • @QuocDatPhung
      @QuocDatPhung  Год назад +3

      Thanks Marcu! Please subscribe and share with your classmates :)

  • @aoyukialquen2835
    @aoyukialquen2835 8 месяцев назад +1

    i have a question, why when i=j, we just fill it up with 0? can someone break it down for me please?

    • @QuocDatPhung
      @QuocDatPhung  8 месяцев назад +1

      It's over 2 years since I've taken this course but let's say i = 1 and j = 2. Then this means you're finding the minimal cost multiplying matrix 1 and matrix 2 right? Let's say that matrix 1 multiply matrix 2 costs 30, whereas matrix 2 multiply matrix 1 costs 20. Now, consider i = j. Here you only have 1 matrix. Nothing to multiply to. Therefore, the cost is 0. Let me know if that makes sense.

    • @aoyukialquen2835
      @aoyukialquen2835 8 месяцев назад +1

      @@QuocDatPhung ​ thank you very much sir, what about the reason we ignore m[2,1] ; m[3,2] etc? I'm sorry if I ask too much, I just want to understand... thank you in advance sir :)

    • @QuocDatPhung
      @QuocDatPhung  8 месяцев назад +1

      @@aoyukialquen2835 No worries! Now remember m(2,2) = 0 right? Because there is no cost when you only have a matrix 2 and matrix 2 only. Since there is only one matrix, there is nothing to multiply to so m(2,2) = 0. Now, what about m(2,1)? There wouldn't be any matrix to consider at all. That's why it's left blank. Let me know if that makes sense.

    • @aoyukialquen2835
      @aoyukialquen2835 8 месяцев назад +1

      @@QuocDatPhung thank you sir, your video and explanation helped me, please keep going with the youtube videos, i support your channel! God bless you

    • @QuocDatPhung
      @QuocDatPhung  8 месяцев назад +1

      @@aoyukialquen2835 Thank you for your support! You can also find all of my algorithm videos here: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @coolestclipsontheinternet
    @coolestclipsontheinternet 18 дней назад +1

    simple enough

    • @QuocDatPhung
      @QuocDatPhung  5 дней назад +1

      Thank you! Please kindly share with your friends and subscribe to support me (it means a lot) ~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @badAtPickingUsernames1988
    @badAtPickingUsernames1988 Год назад +2

    At 5:45 how do we know 138 is the minimum cost?

    • @QuocDatPhung
      @QuocDatPhung  Год назад +2

      Once you complete the table using the formula, the top right value is always the minimum cost. That is how the algorithm works. The proof for the algorithm is long and complex, so it's best just to know that the top right value is the minimum cost. Let me know if that helps.

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

      @@QuocDatPhung Yes. Thank you!

  • @KhoiNguyen-et1uw
    @KhoiNguyen-et1uw 9 месяцев назад +1

    Jesus bro, thanks a ton

    • @QuocDatPhung
      @QuocDatPhung  9 месяцев назад +1

      You're very welcome Khoi! You can find all of my Algorithm videos here: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

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

    Better than Abdul!

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

      Thank you Ethan! Pleased kindly share and subscribe~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

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

    Are u rep,ying with auto reply?

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

      Nope. I always redirect people to my CS playlist. Sometimes people watch something like Selection sort and they ask if I can explain QuickSort but they don't know that I already made it, in the playlist.

  • @nomankhan7190
    @nomankhan7190 8 месяцев назад +1

    WellDone.

    • @QuocDatPhung
      @QuocDatPhung  8 месяцев назад +1

      Thanks Noman! If you enjoy my Algorithm videos, you can find the rest of them here: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @zihanzhou5812
    @zihanzhou5812 Год назад +1

    Good

    • @QuocDatPhung
      @QuocDatPhung  Год назад +1

      Thanks Zihan! Please kindly subscribe. You can find the rest of my Algorithm videos here: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC

  • @SaraKhan-zk8ep
    @SaraKhan-zk8ep 27 дней назад +1

    Best best best 🥹🤌

    • @QuocDatPhung
      @QuocDatPhung  5 дней назад +1

      Thanks Sara Khan! Please kindly share with your friends and subscribe to support me (it means a lot) ~ you can find all of my CS videos in this link: ruclips.net/p/PLeTO6OT3-FKmuxOu4RtupTay1yrMp6QGC