DDSA Solutions

Graph

49 problems · 31 with full explanations

2 Easy21 Medium9 Hard
Graph algorithms model relationships between entities. Core algorithms: DFS/BFS for traversal, Dijkstra for weighted shortest path, Bellman-Ford for negative weights, Floyd-Warshall for all-pairs, and Kruskal/Prim for minimum spanning trees. Represent graphs as adjacency lists (Dictionary<int, List<int>>) for efficiency.

How to practice

To practice Graph problems effectively, start with the Easy problems listed below, trace through each solution on paper, then re-implement without looking. When you can recognise the graph pattern within 30 seconds of reading a new problem, move on to Medium difficulty. Use the related topic pages and our study guide for a structured progression.

Open the full study guide →

Start here (Easy + explained)

All Graph problems