in Algorithms
5,028 views
3 votes
3 votes

Time complexity of Multistage Graph is O(n2) or O(V2) but then some people says it's O(E). So, from O(V2) to O(E) are they taking about dense/complete graphs in which number of edges |E| = |V2|?

Kindly help!

in Algorithms
by
5.0k views

2 Comments

Thanks, Ma'am @srestha.
0
0

2 Answers

2 votes
2 votes
Best answer
In dense graph number of edges are => O(v^2)
thats why we say complexity in worst case will be O(E).
selected by
3 votes
3 votes

In a multi-stage graph algorithm for shortest path, we minimize cost for every edge exactly once. So the Time Complexity is $O(E)$. However, in the worst case, we get a complete graph, which has edges $E = n*(n-1)/2$​, so worst time complexity then becomes $O(E) = O(n^2).$

Note that in this case too, every edge is processed exactly once.

1 comment

THANKS PAAJI
0
0

Related questions