Welcome To Our Presentation • Presented by OUT LINE Definition. Strategies. Algorithmic Steps. Example. Advantages and Disadvantages. Definition • Depth-first search (DFS) is an algorithm for traversing or searching tree or graph data structures. The algorithm starts at the root node (selecting some arbitrary node as the root node in the case of a graph) and explores as far as possible along each branch before backtracking. Algorithmic Steps Strategies Depth-first search (DFS) is three popular Strategies. •Pre-Order: Root->Left->Right. •In-Order: Left->Root->Right. •Post-Oder: Left->Right->Root. Example: • Depth First Search ExampleLet's see how the Depth First Search algorithm works with an example. We use an undirected graph with 5 vertices. Example: • We start from vertex 0, the DFS algorithm starts by putting it in the Visited list and putting all its adjacent vertices in the stack. Example: • Next, we visit the element at the top of stack i.e. 1 and go to its adjacent nodes. Since 0 has already been visited, we visit 2 instead. Example: • Vertex 2 has an unvisited adjacent vertex in 4, so we add that to the top of the stack and visit it. Example: Example: • After we visit the last element 3, it doesn't have any unvisited adjacent nodes, so we have completed the Depth First Traversal of the graph. Advantages and Disadvantages • Advantages Of DFS: 1. The memory requirement is Linear WRT Nodes. 2. Less time and space complexity rather than BFS. 3. The solution can be found out without much more search. • The disadvantage of DFS: 1. Not Guaranteed that it will give you a solution. 2. Cut-off depth is smaller so time complexity is more. 3. Determination of depth until the search has proceeded. ANY QUESTION ? THANK YOU