Dijkstra Algorithm Coding C++ | Shortest Path | Implementation | Graphs | Greedy

แชร์
ฝัง
  • เผยแพร่เมื่อ 26 ก.ย. 2024

ความคิดเห็น • 81

  • @teetanrobotics5363
    @teetanrobotics5363 4 ปีที่แล้ว +38

    I feel that this TH-cam channel has the potential to be one of the best competitive coding channels on entire TH-cam. Could you please organize all the videos of your channel into respective playlists ? Again thank you for your amazing service.

  • @saif0316
    @saif0316 3 ปีที่แล้ว +27

    You're the ONLY one who actually showed me how to code Dijistra's algorithm. Everybody else (including my lecturers) just spent 20 minutes explaining how they would do it, how it works, but never got around to actually explaining correct how to do it. Ty so much! I have a working Dijkstra's algorithm now and I can begin studying this thing and utilizing it for my other projects. Thanks again!

    • @FriendlyDeveloper
      @FriendlyDeveloper  3 ปีที่แล้ว +1

      Thank you so much. Do check out my dynamic programming deep dive series

    • @ThetubeguyNo1
      @ThetubeguyNo1 2 ปีที่แล้ว

      beautiful

  • @biancaar8032
    @biancaar8032 8 หลายเดือนก่อน +1

    You literally saved me...I was crying because I didnt understand this for the lab exam...but now I get it..Thanks

  • @swrhsn6300
    @swrhsn6300 4 ปีที่แล้ว +3

    the way you explained it , it took me just half an hour to code it ... respect

  • @aniket7512
    @aniket7512 4 ปีที่แล้ว +7

    Great video man.Thank u for the video cuz it explains pretty much better as the other videos on YT were not code specific. 😁👍Glad to find your channel. Please guide and upload DS based code videos !!! Thanks Again.😘

    • @aniket7512
      @aniket7512 4 ปีที่แล้ว +1

      Could u please upload the source code ???

    • @FriendlyDeveloper
      @FriendlyDeveloper  4 ปีที่แล้ว +1

      Omg 🤩 thank you so much for your sweet words bro 😃 😃. Loved it :)

    • @FriendlyDeveloper
      @FriendlyDeveloper  4 ปีที่แล้ว +2

      Sure , here is the source code link :
      github.com/nateshmbhat/ada-lab-sit/blob/master/src/Greedy/Dijkstra%20algorithm/main.cpp

    • @ThetubeguyNo1
      @ThetubeguyNo1 2 ปีที่แล้ว

      bilkul sahi kaha

  • @lac2275
    @lac2275 6 หลายเดือนก่อน

    NIce work bro. I recently went over Dijkstra algo from my algorithms course but was having issues with the implementation. Thanks!

  • @Tbm4545
    @Tbm4545 8 หลายเดือนก่อน

    Wow bro this is a unique and different way of teaching, it just teaches dijkstra along with how to code, its very diff from other videos on yt

  • @bongisiphomntambo6494
    @bongisiphomntambo6494 2 ปีที่แล้ว

    This is the best and easiest implementation which I have come across thus far!!

  • @mikehuang8593
    @mikehuang8593 4 ปีที่แล้ว +5

    Isn't is better to use a priority queue which has a time complexity of O(log n) removal and retrieval time instead of iterating through all elements to get a O(n) time complexity? If you would use a priority queue it would therefore run faster and where wouldn't be so much to code. Apart from that the video is pretty neat!

    • @borgir6368
      @borgir6368 2 ปีที่แล้ว

      yeah but it will increase insertion time

  • @poCenilnO
    @poCenilnO 4 ปีที่แล้ว +3

    I believe there's a small typo in the input values shown in the (commented) section of code.
    The image shown at 2:07 has no link from node 7 back to node 0. The inputs in the (commented) code at 2:10 have a value of '8' in [0][7] and [7][0].
    According to the image, those should be '0'.
    Also, the values for [1][7] (value of '8') and [7][1] (value of '11') should be the same (the image shows there's a weight of '8' between nodes 1 and 7).

    • @hitsgamingparadise5243
      @hitsgamingparadise5243 3 ปีที่แล้ว

      Yeah it is an error!!

    • @user-georgeisme
      @user-georgeisme ปีที่แล้ว

      I am trying to correct this array.
      Am I correct?
      0 4 999 999 999 999 999 0 999
      4 0 8 999 999 999 999 8 999
      999 8 0 7 999 4 999 999 2
      999 999 7 0 9 14 999 999 999
      999 999 999 9 0 10 999 999 999
      999 999 4 14 10 0 2 999 999
      999 999 999 999 999 2 0 1 6
      999 8 999 999 999 999 1 0 7
      999 999 2 999 999 999 6 7 0

  • @TheOfficialnF
    @TheOfficialnF 4 ปีที่แล้ว +5

    Please consider uploading source code in next tutorials. It's a real hassle having to scroll through the video for finding one line. Other than that, perfect video!

    • @FriendlyDeveloper
      @FriendlyDeveloper  4 ปีที่แล้ว

      Yes, will add the source code now. Thanks :D

  • @Princess-ly9em
    @Princess-ly9em ปีที่แล้ว +1

    Output?

  • @mohnish.deshpande
    @mohnish.deshpande 3 ปีที่แล้ว +2

    You are talented bro!!!
    I am an Aussie-Indian and have massive respect for such bright/smart Indian guys.

    • @dingdong3021
      @dingdong3021 3 ปีที่แล้ว +1

      Not one care if youre aussie indian

    • @ThetubeguyNo1
      @ThetubeguyNo1 2 ปีที่แล้ว

      i am a brightsmart indian guy

  • @kumaraditya1419
    @kumaraditya1419 4 ปีที่แล้ว +3

    i am not able to understand the ( int get Nearest) part.....plz explain......btw great video

    • @FriendlyDeveloper
      @FriendlyDeveloper  4 ปีที่แล้ว

      nearest node means , that node which has the least distance (weight) from the current node. In dijkstra algorithm , in the first step , we are supposed to first get the nearest node that is not yet visited.

  • @brionesalbertjr9051
    @brionesalbertjr9051 2 ปีที่แล้ว

    How can I have my cost matrix be placed in the code already, and not needing the user to input it?

  • @kirkb2665
    @kirkb2665 3 ปีที่แล้ว

    For your display function, on line 50, add
    after cout

    • @poCenilnO
      @poCenilnO 3 ปีที่แล้ว

      If you need the code to flush immediately after printing that, you could alternately use `std::endl`.

    • @kirkb2665
      @kirkb2665 3 ปีที่แล้ว

      @@poCenilnO Both
      and endl will work.

  • @shrutiomatic
    @shrutiomatic 2 ปีที่แล้ว +2

    9:33

  • @Bingo901
    @Bingo901 ปีที่แล้ว

    Why would you write C++ as if you write plain old C ?

  • @emosuarez3905
    @emosuarez3905 2 ปีที่แล้ว

    Excelente tutorial, muy bien explicado

  • @abhijitroy7502
    @abhijitroy7502 2 ปีที่แล้ว

    Thank you very much for this useful video

  • @kristoforo4178
    @kristoforo4178 4 ปีที่แล้ว +2

    Those animations when typing and moving the cursor look so great, what extension for Visual are you using?

  • @toanvan5575
    @toanvan5575 2 ปีที่แล้ว

    Your work helped me a lot in my DS assignment, but in the assignment my professor adding one condition that there is no loop, which confused me a little bit. I wonder if you can help me to explain it. btw, great video man!

  • @asaduzmn
    @asaduzmn 4 ปีที่แล้ว +1

    Thank you very much for uploading very useful video. Keep doing, You are a very good instructor. Best of luck

  • @adarshsrivastava6599
    @adarshsrivastava6599 4 ปีที่แล้ว +1

    bro can u explain why in while loop parnode=parent[parnode];

    • @FriendlyDeveloper
      @FriendlyDeveloper  4 ปีที่แล้ว

      Hi Adarsh. I have explained that in detail in my explanation video. Check it out. Link is in the description

  • @Oounayo
    @Oounayo 4 ปีที่แล้ว

    Hi. When I put in the number of vertices - ->9, I don't get any output. Same code and all. Do you know what could be wrong?

  • @tusharjain4108
    @tusharjain4108 4 ปีที่แล้ว +4

    Hey, excellent work, when will you upload videos on all the algorithms like prims, pathfinding etc pls tell

    • @FriendlyDeveloper
      @FriendlyDeveloper  4 ปีที่แล้ว

      Hi Tushar! Thanks. As of now I'm making videos on dp. But I definitely want to make vids on the topics you suggested too. Stay tuned. 😁🎉

  • @heregoesnothin4991
    @heregoesnothin4991 4 ปีที่แล้ว

    How can I input the cost matrix?

  • @bhavyaratra5461
    @bhavyaratra5461 3 ปีที่แล้ว +1

    thanks bro

  • @maksymkukharenko7800
    @maksymkukharenko7800 3 ปีที่แล้ว

    thank you, man

  • @matviyberezovskiy2372
    @matviyberezovskiy2372 3 ปีที่แล้ว

    Nothing happens after I entered a cost matrix, the source code line isn't showing. How could I fix that?

    • @saif0316
      @saif0316 3 ปีที่แล้ว

      I think you type "1" at the end.

    • @saif0316
      @saif0316 3 ปีที่แล้ว

      Because this tells the program to start at the first "node"

  • @SzrIsTaken786
    @SzrIsTaken786 2 ปีที่แล้ว +1

    Actual G

  • @priyankajayan6221
    @priyankajayan6221 4 ปีที่แล้ว

    its fine sir good .....could u pls post a video for all k shortest path?

  • @imagiofrancis7289
    @imagiofrancis7289 3 ปีที่แล้ว

    wont we need the same header file for it to work'
    yes im new and dont know much

    • @borgir6368
      @borgir6368 2 ปีที่แล้ว

      do you still need help?

    • @senayshishay6041
      @senayshishay6041 ปีที่แล้ว

      @@borgir6368 yo I need help

  • @ilyazahraee9333
    @ilyazahraee9333 2 ปีที่แล้ว

    very good

  • @basusdiaries6103
    @basusdiaries6103 4 ปีที่แล้ว

    It didn't show the cost of 0 for 1

    • @kirkb2665
      @kirkb2665 3 ปีที่แล้ว

      On line 50 change the code to
      cout

    • @ThetubeguyNo1
      @ThetubeguyNo1 2 ปีที่แล้ว

      That is very sad

  • @SarasTiffinCorner
    @SarasTiffinCorner 4 ปีที่แล้ว

    this is so cool

  • @skystar7350
    @skystar7350 3 ปีที่แล้ว

    so similar to Prim algorithm!

  • @badabeta6973
    @badabeta6973 3 ปีที่แล้ว

    pro 👏👌

  • @shaikhsamee9380
    @shaikhsamee9380 2 ปีที่แล้ว

    Ye matrix chahiye

  • @dingdong3021
    @dingdong3021 3 ปีที่แล้ว

    "NOTTOOO" MAAAAN. Hahaha

  • @GadgetPulseShorts
    @GadgetPulseShorts 3 ปีที่แล้ว

    i think i just puked... that looks so hard

  • @tasnimsamira9330
    @tasnimsamira9330 4 ปีที่แล้ว

    which editor is it?

  • @stephanbotes5865
    @stephanbotes5865 4 ปีที่แล้ว

    The best video I've seen so far.