Coding & Algorithms (DSA)
Graphs & Traversal
6 practice questions. Free questions open a full answer guide; the rest unlock with Pro.
- If you're traversing a graph that may contain cycles, what do you need to track, and what goes wrong if you don't?
- How would you detect a cycle in a directed graph, and why isn't a simple visited set enough the way it is for an undirected graph?Go Pro
- For finding the shortest path in an unweighted graph, why is BFS the right traversal and DFS the wrong one, and what changes the moment the edges carry weights?Go Pro
- A recursive depth-first traversal works fine in testing but crashes with a stack overflow on a large production graph. How do you reason about and fix this, and what trade-offs does your fix introduce?Go Pro
- What's the practical difference between BFS and DFS for traversing a graph, and how do you choose between them and avoid getting stuck on cycles?Go Pro
- What is the difference between breadth-first search and depth-first search on a graph, and how do you decide which to use?Go Pro
Want questions matched to your role? Paste a job title, job description, or CV for a personalized set, or go Pro to unlock the full bank.