What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of n vertices?
View worked solution
Answer: C
The Bellman-Ford algorithm is used to find the single-source shortest paths in a weighted graph. Its standard time complexity is given by:
where:
- is the number of vertices.
- is the number of edges.
For a complete graph with vertices:
- The number of vertices is .
- The number of edges in a complete graph is (for undirected) or (for directed). In both cases, the number of edges is .
Substituting these values into the complexity formula:
Hence, the correct option is C.
Free practice · Your answers on this page are not saved.
