Traversal

You might also like

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 17

TRAVERSAL

The process of visiting each vertex is called graph


traversal.
No root vertex hence we can choose any vertex as
starting vertex.
Different starting vertex create a different sequences.
Keep track of visited vertex.
TRAVERSAL

DEPTH FIRST SEARCH


BREADTH FIRST SEARCH
DEPTH FIRST SEARCH
Depth First Search (DFS) algorithm traverses a graph
in a depthward motion .
It  uses a stack to remember to get the next vertex to
start a search.
IDEA
Visiting a vertex.
Exploration of vertex in depthward motion.
To go in forward (in depth) while there is any such
possibilty,if not then backtrack
Example:Step 1
Step 2
Step 3
Step 4
Step 5
Step 6
Step 7
Step 8
Step 9
TREEE
A

C F
Time complexity
Big O(V+E) where V is number of vertices in the graph
and E is number of edges in the graph.
ANY DOUBT
THANK YOU
FOR ATTENTION

You might also like