What is the time complexity of Depth-First Search (DFS)?
What is the time complexity of Depth-First Search (DFS)?
Approach: Analyze visits to vertices and edges.
O(V + E), where V is vertices and E is edges. It explores as far as possible along each branch before backtracking.
Follow-up: When would you use DFS over BFS?
Key concepts: stack, recursion.