Graphs Interview Questions
In a coding MCQ: which algorithm finds shortest paths in an unweighted graph? — spoken sample answer for Indian interviews.
- 5Questions with answers
- 3Difficulty levels
Questions (5)
Browse beginner, intermediate, and advanced questions with answers — hide them when you want to self-test.
In a coding MCQ: which algorithm finds shortest paths in an unweighted graph?
On an unweighted graph, BFS from the source gives shortest path by number of edges. Dijkstra is for non-negative weights. Bellman-Ford handles negative weights. DFS does not guarantee shortest paths. Prim is for MSTs, not shortest paths. I would mark BFS.
Dijkstra versus BFS for shortest path?
BFS if unweighted. Dijkstra if non-negative weights. Negative needs Bellman-Ford. I would not Dijkstra an unweighted grid.
Adjacency list versus matrix for a sparse graph?
List O(V+E) , matrix O(V^2) . Sparse social graphs want lists. Matrix is O(1) edge check. I would not matrix a million-node graph.
Cycle in a directed graph?
DFS with a visiting/grey state, or Kahn failing to process n nodes. Undirected parent-skip DFS is the trap option on a directed MCQ.
Topological sort exists only if?
The graph is a DAG. A cycle means no topo order. I check Kahn count versus n. I would not topo an undirected graph without orienting edges.
Practice with AI mock interviews
Run Aptitude mock interviews with AI follow-ups, instant feedback, and analytics on AiLx.
Free to start · No credit card required