Design an algorithm for DFS and BFS traversal methods

Design an algorithm for DFS and BFS traversal methods. Comment on its efficiency. Apply the same for the given graph

Answer:-

Algorithm : DFS

ALgorithm: BFS

Efficiency:-

Traversal Time : Θ(|V|2)

for adjacency list representation Θ(|V| + |E|).

V=no of vertices, E=no of edges

DFS:

BFS:

Leave a Reply

Your email address will not be published. Required fields are marked *