Depth First Search in Graphs
This lesson will teach you how to write a recursive code for depth first search in graphs.
What is Depth First Search?
Depth First Search is a way to traverse and search all nodes in a graph. This traversal algorithm works in such a way that it starts from the root node and then traverses all the way down that branch until it reaches the leaf, i.e., the last node with no other children, and then backtracks. This follows until all nodes are traversed. The illustration below shows a better understanding of DFS
.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.