algorithm - Is the worst time complexity of BFS in a graph traversal n+2E? -


i understand time complexity of bfs in graph traversal o( v + e ) since every vertex , every edge explored in worst case.

well,is exact time complexity v+2e ??

every vertex explored once+ every adjacent vertices

the sum of degree of vertices in graph= no of edges*2= 2e

thus time complexity n+2e..am correct?

for random graph, time complexity o(v+e): breadth-first search

as stated in link, according topology of graph, o(e) may vary o(v) (if graph acyclic) o(v^2) (if vertices connected each other).

therefore time complexity varies fromo(v + v) = o(v) o(v + v^2) = o(v^2) according topology of graph.

besides, since |v| <= 2 |e|, o(3e) = o(e) correct, bound looser.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -