4.7 [New] Traveling Salesman Problem - Dynamic Programming using Formula

Поділитися
Вставка
  • Опубліковано 2 жов 2024
  • Traveling Salesman Problem - Dynamic Programming - Explained using Formula
    PATREON : www.patreon.co...
    Courses on Udemy
    ================
    Java Programming
    www.udemy.com/...
    Data Structures using C and C++
    www.udemy.com/...
    C++ Programming
    www.udemy.com/...

КОМЕНТАРІ • 142

  • @Nex_Addo
    @Nex_Addo 5 років тому +145

    You are going to single-handedly get me through my algorithms course. It's so clear, almost obvious, when you explain these things, where seemed so murky when I first heard them. Very much appreciated.

  • @ayasswain
    @ayasswain 5 років тому +64

    The best algorithm explaining teacher I have ever seen. Thanks Abdul Bari sir.

  • @niranjanreddy6334
    @niranjanreddy6334 4 роки тому +37

    Abdul Bari sir I randomly landed in your page , after that I cant stop myself from binge watching all your Algo videos , your videos are amazing n Iam loving it

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

      Algo ki sb videos dekh kr ke bol skte ke yr mera kafi had tk algorithm clear ho gya
      Mtlb fir me ja kr k codeforces wagera ki c type problems solve kr pao ga

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

    11:36 apke sath ek chota sa prank hua, camera ke saamne dekh ke smile karde

  • @arpitaarpi7015
    @arpitaarpi7015 4 місяці тому +2

    Dear sir,
    This semester is very short, 3 months approximately
    So our professor can't complete the whole syllabus
    But our college professor is referring your channel for learning
    You are awesome sir❤

  • @mkhussain3099
    @mkhussain3099 2 роки тому +2

    Cannot see overlapping sub problem

  • @AnitShrestha
    @AnitShrestha 5 років тому +11

    Thank you.
    I found deriving the formula, than implementing one more effective. But it was nice to see the other way as well.

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

    Good, is this part of some of your Udemy course. Please advise.

  • @SadisticShade
    @SadisticShade 5 місяців тому +1

    For my own reference:
    final path : {1,2,4,3,1}

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

    Awesome explanation Sir... 👍👌
    Thanks alot... 💕

  • @Deepak-jk1eh
    @Deepak-jk1eh 4 роки тому +5

    this video is much clear than previous one
    give a medal to this man

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

    If in the source matrix, position [3,1] value we change it as value '0'. Then what should be the Path?

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

    Thank you very much. You are a genius. 👍👍🔝🔝🙏🙏👌👌

  • @vishalc832
    @vishalc832 4 місяці тому

    00:01 Explaining the traveling salesman problem using dynamic programming formula.
    02:15 The formula explains how to find the minimum cost for visiting the remaining vertices.
    04:12 Finding the minimum value by using dynamic programming formula
    06:06 Dynamic programming for solving traveling salesman problem
    08:27 Discussing the recursive tree execution for solving the traveling salesman problem using dynamic programming.
    10:27 Dynamic programming is done with tabular values.
    12:43 Finding smallest values first using dynamic programming
    14:47 The shortest route for the Traveling Salesman Problem using Dynamic Programming is 35.

  • @wirito
    @wirito 4 роки тому +4

    Professor, I asked you this in a different video but I have noticed the following:
    If I click on your course for data structure, it sends me to Udemy with a price of $10 which is correct but it clearly says that this offer is for “new students only”. Since I already have an account, as soon as I log in the price goes up. I could create a new account with a different email but I am hoping you can look into this.
    I have also noticed that at random times on different days, the offer is different. Sometimes is $170, other times is $90, or $19 etc. I don’t believe the offer will be $10 during thanksgiving promotion as you stated. But even if it is, please let me know if the only option for me is to create a new account so that I can pay the $10.
    I am a college student and while I could pay $20 (which is what it goes up to when I log in if the offer is $10) I am suffering from greedy syndrome. You see, since you have already advertised it as $10 then I only want to pay $10 :). That’s how greedy algorithm works professor! I can’t go on paying $20 when there clearly is a lower weight Lol
    Please let me know!

  • @jyotsnapriyadarshi8016
    @jyotsnapriyadarshi8016 4 роки тому +4

    Sir please provide the code also for some of the algorithms of which code has not been provided .

  • @mohammedkhan7029
    @mohammedkhan7029 8 місяців тому

    kya yaaro chale jaate aisich class se sikhaana chodhke
    unsubscribe dislike

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

    what's the time complexity of this algorithm?

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

    what's the use of making table.....I mean what optimization we are achieving by using dp

    • @diegochicurel4724
      @diegochicurel4724 6 місяців тому

      It would have been nice if he showed the table at the end. But basically, you start from the bottom and fill the values in the table, then you don’t need to do recursion or anything else, just fill the table and check if the values are already defined (they will if we do it this way)

  • @Wizzy404
    @Wizzy404 7 місяців тому +1

    you the GOAT at this.

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

    a goldmine in youtube

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

    Hello Sir,
    Which reference or standard book is preferred for referring algorithms ?

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

      Introduction to algorithm by comren

  • @VijayKumar-tt6tj
    @VijayKumar-tt6tj 4 роки тому +1

    Sir, I'm a great fan of your videos, You make things really easy for us no matter how complex the problem statement is.
    Since the time complexity of this algorithm is not polynomial, AFAIK we can just find the MST (Minimum Spanning Tree) and can add the Cost from last vertex to the source to the final result. This way we can have only O(E log V) complexity? Please correct me if i'm wrong?

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

      You cannot revisit a city in the standard travelling salesman problem.

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

    Amazing content! Thank you !

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

    Incredible Explanation!!

  • @nayba100
    @nayba100 8 місяців тому

    Where i can find the first formul that you used. Can you name your source please?

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

    At -5:41 jo pachak hua , sir kehte ye method to lamba hai ye nahi karna 😭 yaar ek din pehle padhrai aur ye dekhne ko mile , LOL ho gaya 😂

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

    thank you so much for this video.. i was a little confused with the formula..
    now i feel dumb for not understanding it before.. 😅

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

    very good explanation sir.....guys watch him if u want to learn

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

    Can somebody give me the previous video on traveling salesman problem he is referring to please?

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

    I got more benefits by learning from this video,it is very nice video👌.

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

    If there are more vertices present, say 6, then this algorithm becomes almost too huge to handle and cumbersome!!!

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

      it is appearing so but see from computer's perspective ..when we gonna program then its just A matter of a loop for controlling value of k.

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

    Sir can we do exactly in exam like drawing tree and writing remaining vertices???

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

      Depends what type of pattern your university follows .....

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

    @Abdul Bari What will be the time complexity of TSP when done this way?
    I am guessing Tabulation will reduce some amount of time but ultimately we are having to consider all possible routes from all possible vertices. Thus O(n!) correct?

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

    In an iterative approach, you can simply solve it as you show in the tree diagram.

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

    As usual AWESOME explanation by Abdul Bari sir. Kudos to you for explaining complex topics in easy and simple terms.

  • @rohitkandula8493
    @rohitkandula8493 11 місяців тому

    You are a divine god for me ,tomorrow i have exam learning today from ur channel😊✨🔥

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

    Thanks a lot SIR! very helpful :)

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

    Very nice explanation sir super super

  • @reddy6131
    @reddy6131 4 місяці тому

    But u didn't say the shortest route

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

    What is the vedio no. For previous vedio on this topic as said by sir?

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

    Very good explanation, watched lot of videos :) Thanks a lot for such awesome content.

  • @vishalc832
    @vishalc832 4 місяці тому

    Plot twist at 11:41

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

    how are we gonna use tabulation method for this one?

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

    Sir can you please solve for s1=abbacdcba and s2=bcdbbcaac

  • @ramaarahatekar1570
    @ramaarahatekar1570 9 місяців тому

    so how and what are we supposed to write it in college university end exam? I mean, where do we start? Do we draw the tree with sample calculations or do we directly do calculations by formula?

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

    Sir can you explain cutting plane algorithm

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

    What about the return path - imagine u have the case where the return path for a vertex is shorter if we use an indirect route. Would you just run the algorithm backwards?

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

    Superb explanation Sir hatsoff🙏🙌🙌

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

    algo bhi bata dete toh thek rahta..................hehehe

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

    Where is previous video sir? Tmw is my exam can you give the link ?

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

    Saviour ❤️

  • @rohitkandula8493
    @rohitkandula8493 11 місяців тому

    The Man The Myth🫶🔥

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

    How to find the path?

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

    thank you sir thank you so much 🙏🙏🙏

  • @RohitKumar-xn8ez
    @RohitKumar-xn8ez 4 роки тому

    Sir, why C[2][1] and C[1][2] have different values and similarly for others.

    • @justwanttoknow4621
      @justwanttoknow4621 4 роки тому +4

      1st city se 2nd city jane pe Ola mili bro
      Aur 2nd se 1st jane pe uber
      Ab bhai jo mehnga h wo mehnga hai🙅‍♂🤷‍♂😛
      Just kidding
      Actually they are predefined weights of path available for the salesperson.
      Suppose it like a two different root from going 1 location to another location.
      Assume each vertex as a city/country in the world and there are multiple paths for every city from another city. The available data is just the indication of the salesmen didn't choose the same path.
      Agra->Delhi
      Delhi->Agra
      There are multiple roads available for this
      Assume A(agra)(delhi) = 12
      and A(delhi)(agra) = 13
      Then the path for reaching delhi and returning back from there might be different.
      It's just given.
      Hope you got it.

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

    Thanks for the tutorial. I would like to just add one note. Maybe it is better to go through tree as Depth-first search not Breadth-first search, because I think recursive algorithm use Depth-first Search.

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

    thank you sir for your easy explanation. the topics which i felt hard in class, you explained it so understandable.

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

    how do you do the table without writing the recursion tree first? we have to write the recursion tree in order to know the later values

    • @Mansoor-qf3mw
      @Mansoor-qf3mw 3 роки тому

      Watch few of his prev. videos on DP u will get it. In a table u don't find 'later' ones but 'previous' ones or from where the subprob came. Actually if u find the value of the smallest subproblem then u would be able to find the answer to thelarger subprob and so on.. Inshort u start from small and then form large.

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

    Long but easy question with awesome explanation!💫

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

    Finally got it thanx

  • @mona5711
    @mona5711 6 місяців тому

    legendary thanks a lot!!

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

    Thank you so much sir 👍👍👍🙏🙏🙏

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

    Sir you are awesome.. Thank you

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

    thank you very helpful

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

    Paatal Lok,s Jaideep Ahlawat.👍

  • @AnkitSoni-vm5od
    @AnkitSoni-vm5od 6 років тому +1

    Your algorithm lectures is really awesome....!!

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

    Is it a bottom up approach?

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

    Awesome 👍🏻👏🏻

  • @ريماآلنزال
    @ريماآلنزال 3 роки тому

    Please, I want an algorithm for this problem. I want to transfer it to program c # :( if you allow

  • @hughjanus5342
    @hughjanus5342 9 місяців тому

    We love you sir!!!!

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

    Sir, why don’t you swap this video into the playlist instead of the old one.

    • @Shivam-vr6eh
      @Shivam-vr6eh 5 років тому

      Abdul Bari Sir my question is Can we use that old video method for Salesman Problem using dynamic prog?

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

    It will be found in hindi

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

    Thank you so much Sir. You make it really easy to grasp and apply these concepts. I am even doing your course on Udemy. Hope to see more of your content and your channel grow even vast. Best Wishes.

  • @pavan7432--
    @pavan7432-- 11 місяців тому

    11:37

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

    Thank you very much , May Allah bless you

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

    Thank you for your hard work.

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

    Sir how do we do the table without writing the recursion tree first? we have to write the recursion tree in order to know the later values

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

      simple find 2 to null three to null four to null then get the values similarly 2 to 3 2 to 4 then 3 to 2 and 3 to 4 etc . Or use the formula which he's given in the beggining of this video (g[i,s] one ).

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

      @@manishrai6845 i think if using formula we have to do like a top down memoization dp, i can't think of a effective way for bottom-up dp yet, like how do we know the remaining set if starting from the bottom (from 2-> null etc.)?

  • @bhuppidhamii
    @bhuppidhamii 9 місяців тому

    Thankyou sir

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

    You are awesome sir , it's very nice and clear explanation. 👏👏👏

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

    Can we apply a dijikistra algo to find the path ...

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

      No, because you've to traverse back to the source vertex.

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

    thank you sir

  • @LocNguyen-mn4dd
    @LocNguyen-mn4dd Рік тому

    thanks

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

    Nice

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

    One Doubt! The formula you explained is for minimum spanning tree. I think you should explain the last condition when a set is empty we have to return distance from the last node to the starting node.
    Anyways, Its been great to watch your videos. Kudos to you!

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

    excellent explanation sir..... please explain the implementation of algorithm too...!

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

    Thank you sir

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

    🙏🙏🙏

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

    11:07

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

    sir LCS problems I think u forget??

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

    great explanation.

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

    n 2^n?

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

    .

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

    Best teacher for Algorithms

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

    best playlist in algorithm cheers

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

      Bhaiyaa ye series complete kr ne se algorithm ka kaafi part cover ho jye ga

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

    Thanks.

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

    Thank you

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

    Great content and easy to understand.

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

    awesome explanation!!!

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

    superb :-)
    Thanks a lot sir :-)