Sections


Main-Menu

header image

Depth-First search


The Depth-First search explores each possible path to find the path’s conclusion or the goal. If the path does not contain the goal the search tries another path by backtracking. The following image shows the path the search takes when trying to find the goal ‘f’:
dfs.JPG
As you can see, the search almost had to check every node in order to find the answer, but it did find the right answer. This search is very reliable but sometimes can take a long time or even turn into an exhaustive search (a search that looks a every point until it reaches the goal). The Depth-First search can also be modified to go from the right to the left.
Advantages:
• Always finds the goal
Disadvantages:
• Often can be slow
• Can result in an exhaustive search
• Can get stuck in long paths that don’t the goal


Related Articles :



Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

Shaadi.com Matrimony - Register for FREE