Q1PYQ · 2025 · 7 Nov S1
What is the time complexity of the Floyd–Warshall algorithm for a graph with n vertices?
- (A) O(n³)
- (B) O(n log n)
- (C) O(n²)
- (D) O(2ⁿ)
Answer: (A) O(n³). Three nested loops over all vertices. It solves the all-pairs shortest path problem using Dynamic Programming.