Graph Algorithms for Technical Interviews - Full Course

Поделиться
HTML-код
  • Опубликовано: 8 июл 2024
  • Learn how to implement graph algorithms and how to use them to solve coding challenges.
    ✏️ This course was developed by Alvin Zablan from Structy. Check out Alvin's channel: / alvintheprogrammer
    🔗 Learn data structures and algorithms: structy.net/
    ⭐️ Course Contents ⭐️
    ⌨️ (0:00:00) course introduction
    ⌨️ (0:02:23) graph basics
    ⌨️ (0:07:10) depth first and breadth first traversal
    ⌨️ (0:29:13) has path - structy.net/problems/has-path
    ⌨️ (0:42:11) undirected path - structy.net/problems/undirect...
    ⌨️ (1:00:44) connected components count - structy.net/problems/connecte...
    ⌨️ (1:13:29) largest component - structy.net/problems/largest-...
    ⌨️ (1:24:03) shortest path - structy.net/problems/shortest...
    ⌨️ (1:39:36) island count - structy.net/problems/island-c...
    ⌨️ (1:58:52) minimum island - structy.net/problems/minimum-...
    ⌨️ (2:12:05) outro
    🎉 Thanks to our Champion and Sponsor supporters:
    👾 Wong Voon jinq
    👾 hexploitation
    👾 Katia Moran
    👾 BlckPhantom
    👾 Nick Raker
    👾 Otis Morgan
    👾 DeezMaster
    👾 Treehouse
    👾 AppWrite
    --
    Learn to code for free and get a developer job: www.freecodecamp.org
    Read hundreds of articles on programming: freecodecamp.org/news

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

  • @chriskorbel6796
    @chriskorbel6796 2 года назад +645

    This guy is phenomenal. His course on dynamic programming was exceptionally well done as well.

    • @mauricemarin5810
      @mauricemarin5810 2 года назад +7

      A little old comment, but exactly my thought, I just went through his dynamic programming course and completely agree

    • @akshayagrawal2222
      @akshayagrawal2222 2 года назад +5

      @@mauricemarin5810 same here

    • @elad7264
      @elad7264 2 года назад +5

      Hi, @Chris can you add a link to the dynamic programing course. Thanks

    • @chriskorbel6796
      @chriskorbel6796 2 года назад +1

      @@elad7264 ruclips.net/video/oBt53YbR9Kk/видео.html

    • @kk11223
      @kk11223 2 года назад +2

      Agreed
      after that course, I am so confident on DP.

  • @Randomisticful
    @Randomisticful 2 года назад +145

    Einstein once said "If you are able to explain it to a 5 year old, you understand it yourself". Alvin, you are one of a kind!

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

      Richard Fynman said that.

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

      @@syedtalha1264 I also said that, hey!

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

      Another immortal quote: ‘I stand on the shoulders of giants’ was attributed to Isaac Newton, as it turns out he wasn’t the one who coined it.

    • @frankmasby6099
      @frankmasby6099 3 месяца назад +2

      I can verify that I’m 5 and I do understand this thanks to this video.

  • @kanakmittal3756
    @kanakmittal3756 2 года назад +31

    Man! you have my respect. This was the best course for getting started with graph problems I have ever seen. Thank You so much.

  • @Basta11
    @Basta11 2 года назад +70

    Leetcode - O(n^2) brute force.
    Algoexpert - O(n) linear
    Alvin / Structy - log(n)

  • @radhikatupkary7875
    @radhikatupkary7875 2 года назад +23

    This is phenomenal! I was finding Graph problems so difficult before watching this video, and now they seem fairly easy after watching the entire video! Thanks a ton!

  • @sede189
    @sede189 2 года назад +13

    This course is hands-down, unequivocally fantastic!!! Best useful course I've seen about graphs. It ties together the algorithms with concrete use cases which just clicked. Thank you for the fantastic job!!!!

  • @Niki-pc5zk
    @Niki-pc5zk 2 года назад +9

    This is the only course I’ve found that has successfully got the concept of graphs through my thick skull, it’s been a subject that’s been so hard for me to learn. Thank you for making this!!

  • @hklbly
    @hklbly Год назад +8

    I chose this video after I got an invitation for an online test from a well-known company. This was my only chance since I have never studied algorithm oriented programming.
    I was given a graph problem and handled it correctly with a minor deficiency in efficiency :) Thanks a lot!

  • @ChillAutos
    @ChillAutos 2 года назад +17

    This was amazing. I've watched a bunch of these types of videos over the years and this is the only one that actually made it look easy. I can actually say I understand this now. Thank you.

  • @MARIUTSKI13897
    @MARIUTSKI13897 2 года назад +94

    I'd always been scared of learning graphs, even though I wanted to... but this course took my fear away 😎👍🏻 excelente course, as always!

  • @ragzzytv
    @ragzzytv Год назад +83

    I'm a mid/senior level webdev and I just come back to Alvin's videos when preparing for interview everytime. its so simple and help me rebrush all of them without much hassle. very good work

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

      you probably use parent_id = .. db.Column in your projects, don't you xDDD

    • @shayorshayorshayor
      @shayorshayorshayor 8 месяцев назад

      ​@@ordinaryggew.

    • @callahan7257
      @callahan7257 6 месяцев назад

      @@ordinarygg Don't get it.

  • @Cdswjp
    @Cdswjp 2 года назад +5

    “Later on in the tutorial we’ll go over examples of when u might use one over the other”
    What a breath of fresh air 🙏🏼

  • @utkarshrastogi8791
    @utkarshrastogi8791 2 года назад +52

    Was looking for something like this and can't beleive you just uploaded it!

  • @bambamgam
    @bambamgam 2 года назад +2

    Huge fan of these courses, he's a great teacher and breaks down these problems to be far less intimidating

  • @tobylerone007
    @tobylerone007 2 года назад +2

    This was probably the most useful tutorial I've seen on YT. Great work!

  • @vibhushajain6363
    @vibhushajain6363 2 года назад +2

    Thank you for making graphs so easy for me! Appreciate your patience to make these videos and share

  • @princeadigwe3764
    @princeadigwe3764 2 года назад +10

    How this person managed to explainamy concepts perfectly is superb... We really need people like this guy in the teaching field... I downloaded the video and I ve not regretted at all

    • @jimmybellmon1268
      @jimmybellmon1268 2 года назад

      Me too I just realized Breathe First Traverse is Fibonacci

  • @zeryabalam7042
    @zeryabalam7042 2 года назад +20

    This course is exceptionally well done. Completely understood the theory and implementation behind them damned graphs.

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

    Before watching this course, I dreaded DFS BFS problems. I always used to somehow understand the logic just before the interview and then forget everything. But now, I understand the logic, visualization and how to appraoch it. Thank you so much Alvin and FCC for this. I am definitely going to watch other interview videos. 👍

  • @eternalwanderer8166
    @eternalwanderer8166 2 года назад

    Thank you so much. This is the only video on RUclips which addresses the graph algorithms the way they should be addressed - graphical visualization, pseudocode and actual problem solving.

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

    This is really really a complete tutorial for “Graph based Problems” both in terms of coding Problems, interview preperation including MAANG and even for a new bie.

  • @johnnychang3456
    @johnnychang3456 Год назад +4

    OMG this video is an absolute gem! I used to be baffled by the island problem and just simply memorizing the solution on leetcode, but after following along for two hours, I can confidently code up the solution all by my self! Thank you so much you are a fantastic teacher.

  • @Annant05
    @Annant05 2 года назад +1

    Thanks for the video. To be honest, this is one of the best graph tutorials I have ever witnessed. My core concepts and understanding towards this Data Structure has improved and I really appreciate the efforts you have put in to make this video.🙏

  • @symbol767
    @symbol767 2 года назад

    The best beginner graph tutorial.
    I always come back to this to refresh myself on graphs.

  • @punith023
    @punith023 2 года назад +6

    Thanks Alwin for this great tutorial. I had been trying to understand and get an answer to a similar set of problems for a very long time. You made my day, ...probably my life!

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

    easily the best teacher of algorithms I've ever seen. Alvin spends time going over theory, Big O notation, and common errors. As someone that's never studied algorithms and data structures, all the videos he has done have helped drastically

  • @alessiocelentano6895
    @alessiocelentano6895 2 года назад +5

    I never comment on RUclips, but I love the way Alvin explains concepts. Thanks a lot for your work!

  • @alexneagoe5258
    @alexneagoe5258 2 года назад +2

    I am actually studying C but I have found this video tremendeously helpfull in explaining how graphs are traversed and how not to use return in a bad way when you want to actually make use of recursion to backpedal from dead ends in situations where you don't find your base case.
    thank you again. subscribed!

  • @johnsontian2733
    @johnsontian2733 2 года назад +1

    Thank you Alvin! Your explanation is GOLD!!! It's such a phenomenal tutorial that I find myself learning so much more efficiently!

  • @kelvinmuza7034
    @kelvinmuza7034 2 года назад +3

    My guy, I don't know how to thank you. You have a marvelous way of teaching. This has really helped me a lot

  • @VinodKumar-wh1mq
    @VinodKumar-wh1mq 2 года назад +3

    You're doing an amazing job Alvin👍I'm always on lookout for your contents. Thank you!

  • @mandihaase2744
    @mandihaase2744 2 года назад +1

    All of Alvin's content is amazing! I signed up for Structy after doing this course and the course on trees, and love it!

  • @amarjeetchaurasia2811
    @amarjeetchaurasia2811 2 года назад +5

    Never looked graph so easy to me before I watched this one, thanks! 😊

  • @steventolerhan5110
    @steventolerhan5110 2 месяца назад

    Honestly one of the best tutorials ive come across in my 2 years of coding. Good work Alvin

  • @yadikishameer9587
    @yadikishameer9587 2 года назад +6

    This guy literally changed the way I look at dynamic programming.

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

    Preprocessing the input by storing edges in hashmap: this line took all my fears of not even trying to attempt graph problems to making me feel I could do any graph problems. Thanks for this video ❤️

  • @rahul-qo3fi
    @rahul-qo3fi 2 года назад +4

    watched your lecture on Dynamic Programming and now I am here. You are such a phenomenal teacher, thanks a ton for making these tutorials!

  • @JeremiKress
    @JeremiKress 2 года назад

    Finished my very first fCC course. The pedagogy is excellent, Alvin is a great teacher

  • @brothermalcolm
    @brothermalcolm 2 года назад

    Thanks to the first 30mins of this video alone I was able to extend the idea of adjacency lists and independently solve all the following problems on undirected graphs and grid graphs in just under a week's worth of practice

  • @pz5109
    @pz5109 2 года назад +2

    Just finished the Dynamic Programming from Alvin and now back at the Graph algorithm.

  • @Spaaace
    @Spaaace 2 года назад

    100% the best teacher I've seen. You are legit the best, my dude.

  • @TheBarthinator
    @TheBarthinator 2 года назад

    Wow amazing how you made me understand graphs and I have extreme comfortability with the recursive approach and queue method. Always struggled understanding these implementations in python but as a web dev it made a lot more sense in JS. Thank you for taking the time to make this video!

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

    As an embedded software engineer, I never learned about these kind of algorithms. This is invaluable knowledge for me, thanks for leveling up my skill!

  • @bikkikumarsha
    @bikkikumarsha 2 года назад +2

    Changing lives, one algorithm at a time. Great work Alvin!

  • @ahbarahad3203
    @ahbarahad3203 2 года назад +2

    Thank you Alvin, loved the DP course and this one as well

  • @codecleric4972
    @codecleric4972 2 года назад

    I thought I'd seen the all the greatest of online coding instructors, and then I found Alvin... Seriously these explanations are paced exactly perfectly and ultra clear

  • @yunaf4609
    @yunaf4609 2 года назад

    By far the best video that I have ever seen on this topic, thank you for all the effort you put into this Alvin!

  • @varunshridhar1310
    @varunshridhar1310 2 года назад +107

    The course on DP was a winner. Course on Graph algo is another winner. Hope to learn a lot more from you.

    • @keerthi1070
      @keerthi1070 2 года назад +10

      you are another winner for appreciating him :)

    • @ziggystardust3763
      @ziggystardust3763 2 года назад +6

      @@keerthi1070 you are another winner for appreciating another winner

    • @Tetrax
      @Tetrax 2 года назад +2

      @@ziggystardust3763 you are a winner for appreciating a winner appreciating a winner

    • @ldar6472
      @ldar6472 2 года назад +7

      @@Tetrax this recursive call stack gotta stop somewhere XD

    • @Tetrax
      @Tetrax 2 года назад +2

      @@ldar6472 let’s assume we’re on an alternate universe where leetcode doesn’t have a time limit

  • @theegreatestever2420
    @theegreatestever2420 2 года назад

    Have yet to work on this but want to express my gratitude and wish you greatness in all aspects of your life!

  • @kirillzlobin7135
    @kirillzlobin7135 7 месяцев назад

    Your explanation is ideal. Voice and the way you expalin does not make a listener tired. This is just amazing. Please continue doing your job. It is amazing

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

    This was an elite video. I did the last two questions and did not understand how to approach it or understood what the right answer for those questions. Watch the 2+ hours of video as well as coding it up myself, and everything makes sense. EVERYTHING. I am now able to do one of the toughest topics that I was having trouble with. So BIG Thank You for that.
    P.S. For the last 2 questions, you don't need the visited set, you can flip the land to water or another value altogether. Avoiding the cyclic infinite loop.

  • @harshdhamecha5301
    @harshdhamecha5301 15 дней назад

    I never knew Graphs were that easy!
    You're one of the rarest gems I have come across in my life.
    Followed it all along. Solved all the problems in Python.

  • @tickkun7901
    @tickkun7901 2 года назад

    めちゃくちゃ分かりやすかった!!
    Alvinさんありがとう!!

  • @chibuzorisrael5878
    @chibuzorisrael5878 7 месяцев назад

    Thank you so much, Alvin, I have always been intimidated by graphs. This is the best course you will ever stumble across on graphs.

  • @alexandra_reznikov
    @alexandra_reznikov 2 года назад +3

    Definitely was looking for this! Thanks! ❤️

  • @christinemello694
    @christinemello694 Месяц назад

    by far the best explanation of dfs and bfs that actually makes sense!

  • @Aman-rm1hq
    @Aman-rm1hq 2 года назад

    He makes it look so easy, wish I had jumped across these tutorials earlier. But will use them now.

  • @jayp3573
    @jayp3573 2 года назад

    I learned more from this tutorial then all other tutorials that I watched combined. Great videos man!

  • @adityabyreddy
    @adityabyreddy 2 года назад +5

    This is amazing. I found it really easy to understand the graph algorithms after referring to this video. Great job, Alvin :)
    Small correction in the solution described for checking if a source and destination have a path in an undirected graph. (line no. 8)
    The logic of traversing the neighbors and adding the source node to the visited list has to be part of the condition that validates whether ta node is visited or not.
    if !(visited.has(src)) {
    // add the src to the visitors list
    // recursively traverse through the src neighbors
    }

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

    I literally have no words to express how mind-blowing Alvin is.

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

    this was such a great course, literally understood every aspect of it. Was able to do the problems after your explanations

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

    Thank you for the video. Also to find the minimum sizes of the island, we can use the method that calls the recursive function (parent method) to hold an integer that points to the size of the visited set before the recursive call and then use the difference in size after the recursive call to determine the minimum size. This to me didn't require me to create a new recursive method that returns an integer. However, creating an extra method does have its benefits too.

  • @agustinvargas6973
    @agustinvargas6973 2 года назад +1

    This is fantastic. Makes graphs easy to digest. Thanks for that.
    I did find a minor issue in the island count problem solution.
    It assumes that each row will have the same number of columns. That assumption isn't described in the problem. So a quick fix would be to run the nested loop to the length of the row instead of fixing it to zero. And doing the same for the inbounds check. That would present an issue in the exploration in that there might not be any map in either direction, so you'll have to add an existence check in the explore to account for that.
    This way if a row has less coordinates, or more, it would still work properly.

  • @evieuyenta8764
    @evieuyenta8764 2 года назад

    by far the best tutorial!!! i finally am getting better at this. THANKS A TON!

  • @mounishsavier5774
    @mounishsavier5774 2 года назад

    Your voice is so soothing too! Amazing video, i've always had a bit of a block when it comes to these graph algorithms but your approach/explanations finally helped me grasp them!!

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

    Alvin, you’re one of a kind. Thanks

  • @anthonypark9158
    @anthonypark9158 2 года назад

    just wow on the fact that we're living in a world where we have access to such a quality learning material for FREE. Thanks a lot!!

  • @venkateshkagalavadi7824
    @venkateshkagalavadi7824 2 года назад

    Sooper excited for this!! Thanks you! Your DP course is excellent!

  • @nativeKar
    @nativeKar 2 года назад

    What a great series! Learnt so much in just under 2 hours!

  • @manivannansivaraj7324
    @manivannansivaraj7324 2 года назад

    Thanks for this video tutorial, Alvin!
    It helped me to understand graphs, graph traversals and most common graph related tech interview problems much better.

  • @webcodingoprogrammingtips2090
    @webcodingoprogrammingtips2090 2 года назад +6

    Awesome work! You inspired me to start my coding channel!

  • @Sean-gx1sf
    @Sean-gx1sf Год назад

    One of the most useful videos I've seen for understanding data structures, awesome

  • @alanalmeida7887
    @alanalmeida7887 2 года назад +1

    Thanks a lot! just finished the first section (dfs and bfs) and it got soldered into my brain! well taught!

  • @517Amit
    @517Amit Год назад

    I am following Alvin's last couple of series DP, Graph. Really enjoying his teaching. Appreciate.

  • @kirillzlobin7135
    @kirillzlobin7135 7 месяцев назад +2

    So logical and calm and fantastic explanation. This is just unbeliveble :) How you can explain this stuff so easily. You are the legend

  • @ashleypowell8066
    @ashleypowell8066 8 месяцев назад

    Here because Alvin's DP video was amazing. This is another gem. Thanks!!!

  • @threekingdoms99
    @threekingdoms99 2 года назад

    Thank you, Alvin.
    Your explanation is very clear and easy to understand!

  • @AfnanAlauddinMumu-
    @AfnanAlauddinMumu- Месяц назад

    Just love the way Alvin Zablan teaches... keep it up

  • @kd6164
    @kd6164 2 года назад

    Honestly probably the best explanations for DS&A

  • @everyday___life
    @everyday___life 11 месяцев назад

    Hats off FCC and Alvin. Whenever I see your videos I also get the feeling that I should give back to the awesome community this is .

  • @Mohib3
    @Mohib3 2 года назад

    one of the best instructors. what a beast

  • @paulpapacz3000
    @paulpapacz3000 2 года назад

    Amazing walkthroughs and explanations! Much appreciated 🙏

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

    Thanks so much for uploading this! The approaches are clearly explained

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

    Best video on graphs I have ever seen .

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

    Love you man. You make things so easy. Please do more courses. Will support you to the moon.

  • @doug6577
    @doug6577 2 года назад

    This is awesome! I've been struggling with graphs until I saw this video, great course.

  • @aroncanapa5796
    @aroncanapa5796 2 года назад

    I think this should be the first programming video anyone watches , I was struggling so hard before this

  • @0ffset925
    @0ffset925 2 года назад

    A true master, living legend. thank you so much

  • @MIDNightPT4
    @MIDNightPT4 2 года назад

    Splendid! Alvin is an incredible instructor

  • @rashmikiranpandit3411
    @rashmikiranpandit3411 10 месяцев назад

    Thank you! Exactly what I was looking for to brush up my Graph skills real quick!

  • @franklinghosh4317
    @franklinghosh4317 2 года назад +84

    Wow!, Your DP course was phenomenal, now you came up with Graph theory too, Thank you

    • @AlvintheProgrammer
      @AlvintheProgrammer 2 года назад +13

      Glad to hear you found value in my content! More coming soon.

    • @vinayaktyagi8773
      @vinayaktyagi8773 2 года назад

      @@AlvintheProgrammer what next ?

    • @mz_dreamminister
      @mz_dreamminister 2 года назад

      @@AlvintheProgrammer this is really true! you are the best!

    • @AlvintheProgrammer
      @AlvintheProgrammer 2 года назад +4

      @@vinayaktyagi8773 Likely trees or linked lists next. You can check out my platform, Structy (link in the video description), if you want to check it out early before it premiers on free code camp.

  • @vinayrajagopal5478
    @vinayrajagopal5478 Год назад +28

    This is a great intro to basic graph problems - however we may need a part two to cover more advanced topics such as Union Find, Minimum Spanning Trees, Dijkstras & bellman ford, topological sort, etc.

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

      Sure we totally need. Code interview for wannabe juniors requires some of advanced topics

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

      Guaranteed you won't actually need any of that when actually building something in the real world.

  • @rawatpraveen1000
    @rawatpraveen1000 2 года назад

    wow your explanation is just amazing! Never thought it would so easy.

  • @user-pz3wj3yk2x
    @user-pz3wj3yk2x 10 месяцев назад

    Really awesome walkthrough - thanks Alvin!!

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

    One thing to keep in mind for javascript is when you are using queue the shift operation on array is of O(n) complexity. to make it O(1) you need to implement circular queue class yourself.

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

    Great tutorial Alvin. For python programmers, here is the pattern for largest components (connected components is similar):
    def explore(arr, node, visited, comp_count):
    if node in visited:
    return 0, visited
    visited[node] = 1
    for neighbour in arr[node]:
    comp_count += 1
    explore(arr, neighbour, visited, comp_count)
    return comp_count, visited
    def largestcomponent(arr):
    largest_comp = 0
    visited = {}
    for node in arr:
    if node not in visited:
    comp_count, visited_new = explore(arr, node, visited, 1)
    visited = visited_new
    if comp_count > largest_comp:
    largest_comp = comp_count
    return largest_comp

  • @thobiaslarsen8336
    @thobiaslarsen8336 2 года назад +1

    Thanks FreeCodeCamp and Alvin, you are doing some important work right here and contributing it to a large amount of people. I love you guys

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

    Please do more this guy is amazing.

  • @alyshagilliard7498
    @alyshagilliard7498 2 года назад

    This was so gooooood!! Watching all the other ones. So glad I found this!

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

    Great video Alvin. When you describe it, it seems piece of cake. Good job.