The Floyd-Warshall algorithm is a popular method for solving the All-Pair Shortest Paths problem. What is the time complexity of the Floyd-Warshall…
The Floyd-Warshall algorithm is a popular method for solving the All-Pair Shortest Paths problem. What is the time complexity of the Floyd-Warshall algorithm for a graph with "n" vertices?
Show answerHide answer
Correct answer: (D) O(n^3)
Explanation
Floyd-Warshall runs three nested loops over k, i and j, each from 1 to n, so it takes O(n³) time.