4.1.1 MultiStage Graph (Program) - Dynamic Programming

Поділитися
Вставка
  • Опубліковано 3 бер 2018
  • Multistage graph Program and explanation
    PATREON : www.patreon.com/bePatron?u=20...
    Courses on Udemy
    ================
    Java Programming
    www.udemy.com/course/java-se-...
    Data Structures using C and C++
    www.udemy.com/course/datastru...
    C++ Programming
    www.udemy.com/course/cpp-deep...

КОМЕНТАРІ • 97

  • @farruhhabibullaev3570
    @farruhhabibullaev3570 5 років тому +9

    Super clear. Have been struggling and looking for such clear tutorials for ages. Decided to check your tutorials first for all the topics.

  • @jayuchawla1892
    @jayuchawla1892 5 років тому +140

    Sir, shouldn't the condition instead of c[i][k] + c[k] should be c[i][k] + cost[k] ?

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

      Ya just to avoid confusion

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

      Ha, vo hona chahiye

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

      please watch this playlist for detailed explanation of dynamic programming..ua-cam.com/play/PLeF0b8iqbx4mTBJZ5ukIYj92_B4k2L1-8.html..

    • @code.cracking
      @code.cracking 2 роки тому +3

      yeah that's what I thought, and also P[i] = d[P[i-1]] should be Path[i] = d[Path[i-1]], anyway

    • @tejapraveendevarajuobulase1896
      @tejapraveendevarajuobulase1896 7 місяців тому

      Plz give simple code for backward

  • @AnkitKumar-ih9mt
    @AnkitKumar-ih9mt 5 років тому +16

    fantastic explanation , this tracing with the help of code really makes the concept crystal clear !

  • @dr.rakeshsinghjadon2505
    @dr.rakeshsinghjadon2505 3 роки тому +11

    Very lucid explanation Dear Sir. You are doing a great service to the learners. Please create such video series for artificial intelligence and machine learning.

  • @msozeri
    @msozeri 4 роки тому +17

    May Allah bless you. Thanks for your videos and time. I kindly would like to correct two points; c[i][k] + c[k] should be c[i][k] + cost[k] AND p[i] = p[d[i-1]] should be p[i] = d[p[i-1]];

  • @RyanAwungshi
    @RyanAwungshi Рік тому +1

    i never understand in class that my teacher teach but the way you teach was simple and understandable....thank you sir.....

  • @aritrabelel6083
    @aritrabelel6083 2 роки тому +14

    13:00
    Sir, In the line
    p[i] = 1, (here `i` is already zero)
    So, I think it should be,
    p[1] = 1;
    And in the line
    min = c[i][k] + c[k]
    It should be,
    min = c[i][k] + cost[k];

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

    so simply solved the complex problem, sir upload Videos on the cloud computing, thanks a lot sir

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

    Thank you so much sir❤️❤️ You cleared my subject in End Sem exam🙏🙏🙏

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

    Sir your explanation is so simple and thank you for your free videos. If possible can we expect the videos on turning machine problems.

  • @vaishnvid.6149
    @vaishnvid.6149 6 років тому +27

    Hello sir....can u plz explain us on backward multistage graph??

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

    Great explanation Sir. Thank you very much!

  • @Thepankaz1
    @Thepankaz1 5 років тому

    Isn't it same as greedy approach where we pick the min or max at a given time, here we are simply picking the minimum cost vertices, after we have analysed from sink to source. Is analysing from sink to source the dynamic part of DP ?

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

    do we need to provide no. of stages initially?

  • @subramaniyanvg6367
    @subramaniyanvg6367 Рік тому +1

    God bless you sir with good health and wealth super explanation

  • @thrilleracaste400
    @thrilleracaste400 2 роки тому +1

    Thank you so much sir for all your efforts! Really appreciated. Respect++

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

    Abdul sir is legend for me.

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

    This problem can also be solved using dijkstra's algorithm right ?.. If so which one should we prefer ?

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

    sir,we used tabulation or memoization to solve the multistage graph problem??

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

    Guys, see his video...4.1 , He has explained it amazingly. Thus is the second part of that problem. Hence : 4.1.1

  • @naitikchatterjee8951
    @naitikchatterjee8951 Рік тому +2

    Love you sir, u made it super easy 💌

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

    SIr, please explain how to wirte the alg by transitiong from naive approach to DP approach

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

    Helped me during my exams

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

    Well explained. Hats off

  • @yieytmrooen-dc9hl
    @yieytmrooen-dc9hl Рік тому

    sir we could initialize the minimum with zero and c[i][k] + c[k]>min in the if statement will it work???

  • @joshualiu8551
    @joshualiu8551 5 років тому

    Hi, just a question, so do we need to fill that matrix by ourself? The matrix C which is calculating the distance between each node.

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

    sir thank you so much for these best lectures....sir i have a small doubt that in if loop the condition is c[i][k]+cost[k] < min i think....u wrote it as c[i][k]+c[k] < min....please clarify my doubt sir....

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

      no problem sir....due to ur great explaination we can solve that easily....

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

    absolute legend

  • @jayuchawla1892
    @jayuchawla1892 5 років тому +9

    And also shouldn't the last line be path[i] = d[path[i-1]] ?

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

      @@abdul_bari Sir, thankyou for your kind reply.

  • @vishnuvardhan4093
    @vishnuvardhan4093 5 років тому

    Awesome sir . Thank you

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

    Thank you very much!

  • @syedalinemath917
    @syedalinemath917 5 років тому

    Is it backward multi stage graph. ?

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

    a gold mine in UA-cam

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

    Outer for loop should be decrementing, not incrementing right?

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

    Thank you for your efforts

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

    if inner loop run for n^2 times and outer loop run for n times then if statement will run for n^3 times
    so time will n^3. how it become n^2 please help me through this.

  • @shaikhanuman8012
    @shaikhanuman8012 Місяць тому

    Tqs for giving valuable information sir. I bought your udemy course.

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

    Thank you so much sir 🙏 but sir there is "min = 32767", what does that mean?

  • @PythonisLove
    @PythonisLove 8 місяців тому +1

    HI sir, very nice explanation, can you please create such videos on ML algorithms ?

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

    Why is p[1]=1? Will it remain same for every value?

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

    Sir, wouldn't the time complexity be O(n^3) because there are nested for loops?

    • @PiyushSingh-ut8vu
      @PiyushSingh-ut8vu 3 роки тому

      Sir have explained how many times both loop works .. like for n-1 , inner loop run for only 1 time and if u consider that outer loop runs for n times and every time inner loop also runs for n Times then again time complexity will be (n**2)

    • @Abhishek-ys2io
      @Abhishek-ys2io 2 роки тому

      I'm also thinking same. @Devanshi shah

    • @nipunsamarakoon6526
      @nipunsamarakoon6526 2 роки тому +1

      No it is O(n^2) because first for loop iterates almost n times and each time second for loop iterates 1 to n time. So total is addition of all

  • @shivapriyasnair-ec1vd
    @shivapriyasnair-ec1vd 3 місяці тому

    you are a life saver thank youuuuuu

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

    Thank you Sir..🙏🙏

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

    AslamuAleikumWrWb Sir, won’t p[i] = d[i-1] give same result instead of d[p[i-1]] ?

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

      no....because by doing p[i-1] we are getiing which vertex was explored in the previous stage... simply by doing d[i-1] won't give the correct result always.

  • @RahulKumar-de2rw
    @RahulKumar-de2rw 5 років тому

    Good explanation

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

    That's good work bro

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

    sir why did you assume minimum value as 32767. Is it assumed specifically or we can assume any other value? thankyou!

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

      @Daniel Albesta But why is it necessary to assume the max value? Can we solve without that condition?

    • @vjayvenkat
      @vjayvenkat 2 роки тому +1

      The idea of the inside "for loop" is supposed to get the minimum for that vertex among all edges connected to that vertex and store in min variable. We don't have a minimum to compare with for the first encountered edge so we take the max possible value which 32767 for small signed integers to compare.
      If you don't like this approach of professor you could introduce a "if" before the "if" mentioned to assign the min variable with the first encountered legitimate edges cost without comparing to min like this "if (c[i][k] != 0) { min = c[i][k] =+ cost[k]; d[i] = k; }". This way you don't need to assign min with 32767.

  • @pantsodem9198
    @pantsodem9198 2 місяці тому

    Thank you sir !!!!

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

    In if block c[k] should be replaced with cost[k].
    Great explanation by the way sir 👌🏻👌🏻👌🏻

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

    why start from last stage? can we start from 1st stage? shouldn't be the answer same in both cases?

  • @lahwfsk167
    @lahwfsk167 5 років тому

    Respect sir

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

    Fabulous!!!

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

    For i=7,. Cost[ i ]= min = 32767, coz c[ I ][ k] == 0, but in actual Cost[ i ] should be 5, I don't understand this part...can someone explain this to me?

  • @offset9274
    @offset9274 5 років тому

    Seems we can solve this problem by using Dijkstra algorithm

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

    It looks like size of cost array should be equal to number of stages.

  • @user-zv4sb6ri7y
    @user-zv4sb6ri7y Рік тому

    true mentor

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

    Sir, IN programming somewhere it is written min=32767; How it comes

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

      Of a signed integer.For an unsigned integer it is 65535

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

      Its just that for the first time, c[i] [k] + cost[k] should be less than min and it beacome min for further iterations.
      Aur programming me infinity toh dal nahi sakte, 32767 is the max possible value of signed int

  • @KD-xi9wu
    @KD-xi9wu 3 роки тому +2

    Why min initialised to 32767??
    Any body knows please reply 🙏

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

      So that the weight of that node to the final destination is always less that min(32767) value. You can choose any large value . I use use 1e9+7.

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

    What is the final minimum cost answer?

  • @pravallikagunapu6707
    @pravallikagunapu6707 5 років тому

    d[1]=3 it's not 2. 1+6=7. itbhas the min cost

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

    God of algorithms is here.

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

    Teşekkürler.

  • @moza7137
    @moza7137 10 місяців тому

    *VERY NICE*

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

    Sir, why have you put min = 32767?

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

      min is an arbitrarily large number. It could also be 500000000, or 1000000000000000035432432

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

    Great

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

    👍

  • @AshishSingh-qw4iy
    @AshishSingh-qw4iy 4 роки тому

    good

  • @_VISHALKUMAR-du2nu
    @_VISHALKUMAR-du2nu 8 місяців тому

    is any body has the whole code

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

    Sir...the overall complexity will be O(n³) na??? Because inner for loop complexity is O(n²) as calculated and outer for loop is repeated for n times...So overall complexity will be O(n² * n) = O(n³)...
    Please anyone explain this...

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

      Hi, check his video 1.9 properties of asymptotic notation, your question can be applied to the transitive property. O(n(O(n^2)) = O(n^2)

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

      You don't multiply the the outer and inner loop n's. Add them. Inner one is n² and the outer being n. It's n+n². So the overall complexity would be O(n²)

    • @1maruf
      @1maruf 2 роки тому

      *​ @Joya That's my Boy✌👍*

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

    Saviour of exams

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

    min=C[i][k]+cost[k]

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

    I Think it is not c[k] sir its cost[k]

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

    before 3:11got my brain turning on its own :(