Skip to content
Programming

Graphs: BFS, DFS, Dijkstra and MST

Account required to view full content

Graphs are where the earlier data structures finally pay off, and where a lot of quant coding rounds separate the candidates who memorized snippets from the ones who understand them. A graph is just nodes connected by edges, but that single idea models order books, dependency chains, correlation networks, and routing problems. The four algorithms in this lesson, breadth-first search, depth-first search, Dijkstra, and the minimum spanning tree, are the ones interviewers ask about by name. This lesson builds each from scratch, runs it, and works three real interview questions end to end: Find All Paths, Dijkstra’s Algorithm, and Minimum Spanning Tree (MST). This lesson leans on two earlier ones: BFS uses a queue from Stacks and Queues, and Dijkstra and Prim use the heap from Heaps and Priority Queues.