May 2017
Intermediate to advanced
340 pages
8h 16m
English
Depth first search, or DFS, is a search technique where we start searching from a node and go as deep as possible to the node from the target node through the branches. DFS is different from BFS, and we try to dig deeper instead of spreading out first. DFS grows vertically and backtracks when it reaches the end of the branch and moves the next available adjacent nodes until the search is over. We can take the same tree image from the last section, which is shown as follows:

If we apply DFS here, the traversal will be
. We ...
Read now
Unlock full access