Open In App

Algorithms | Analysis of Algorithms | Question 12

What is the time complexity of Floyd–Warshall algorithm to calculate all pair shortest path in a graph with n vertices?

(A)



O(n2log(n))

(B)



Theta(n2log(n))

(C)

Theta(n4)

(D)

Theta(n3)

Answer: (D)
Explanation:

Floyd–Warshall algorithm uses three nested loops to calculate all pairs shortest path. So, the time complexity is Theta(n3).
Please read here for more details.

Quiz of this Question
Please comment below if you find anything wrong in the above post

Article Tags :