Exams › GATE › Technical
What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of n vertices?
- Θ(n²)
- Θ(n² log n)
- Θ(n³)
- Θ(n³ log n)
Correct answer: Θ(n³)
Solution
The Bellman-Ford algorithm has a time complexity of Θ(n * m), where n is the number of vertices and m is the number of edges. In a complete graph, the number of edges m is Θ(n²), leading to a total time complexity of Θ(n³).
Related GATE Technical questions
⚔️ Practice GATE Technical free + battle 1v1 →