InterviewSolution
Saved Bookmarks
| 1. |
What do you understand about the DFS (Depth First Search) algorithm. |
|
Answer» Depth First Search or DFS is a technique for traversing or exploring DATA structures such as trees and graphs. The algorithm starts at the root node (in the case of a graph, any random node can be USED as the root node) and EXAMINES each branch as far as feasible before retracing. So the basic idea is to start at the root or any arbitrary node and mark it, then advance to the next unmarked node and repeat until there are no more unmarked nodes. After that, go back and check for any more unmarked nodes to cross. Finally, print the path's nodes. The DFS algorithm is given below: |
|