Time Complexity(DFS,BFS)

i want to understand properly the time complexity of dfs and bfs

@dare_devil_007
BFS (Breadth first Search): first you need to know how BFS works, in BFS
algorithm selects a vertex and insert its entire adjacent vertexes in a queue, now
next vertex is picked from this queue and as soon new vertex is picked its
entire adjacent vertexes is inserted in same queue and so on…
So for every vertex you visit you need to calculate its adjacent vertexes,
and it can be reached through edges so complexity =O(V+E)
same coplexity for dfs as in it too we go to all vetices through the edges.
i hope its cleared if yes dont forget to hit like and mark resolved :smiley:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.