Question
What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of vertices?
Official answer and solution
- Official answer
- C
- From
- Official GATE 2013 answer key
Solution
Substitute the vertex and edge counts of a complete graph Kn into the Bellman-Ford time complexity formula.
The Bellman-Ford algorithm finds single-source shortest paths in an arbitrary weighted directed graph :
- It performs passes of edge relaxation.
- In each pass, it relaxes all edges.
- Total running time is .
For a complete graph on vertices:
- Number of vertices .
- Number of edges .
Substituting into the complexity formula:
This matches option C.
Option (C)
Using the edge count of a sparse graph () rather than a complete graph ().
The answer is the one in the official GATE answer key. The solution is this site's own explanation.
Source
- Paper
- GATE 2013 Computer Science and Information Technology (CS)
- Question
- 19 of 65, printed as CS Q.19
- Section
- Computer Science and Information Technology
Report an error in this question
GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.