Back to course home
0% completed
14. Depth First Search
Problem Statement
Write Recursive Approach for Depth First Search (DFS).
Given a graph, perform Depth First Search (DFS) traversal on the graph using a recursive approach.
Example 1:
Graph:
1 -- 2 / \ \ 3 4 -- 5
Output: 1 2 5 4 3
Explanation: Starting from node 1, we visit its adjacent nodes in order: 2, 5, and 4. From node 4, we visit node 3.
Example 2:
Graph:
0 -- 1 -- 3 \ | 2
Output: 0 1 3 2
Explanation: Starting from node 0, we visit its adjacent nodes in order: 1 and 2
.....
.....
.....
Like the course? Get enrolled and start learning!
Table of Contents
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible
Contents are not accessible