Skip to content
Official PYQ · 2013

GATE CS 2013 Q19 — Shortest Paths (Dijkstra, Bellman-Ford)

Explain with AI

What is the time complexity of Bellman-Ford single-source shortest path algorithm on a complete graph of n vertices?

Choose one option
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:

Time Complexity=Θ(V⋅E)\text{Time Complexity} = \Theta(V \cdot E)

where:

  • VV is the number of vertices.
  • EE is the number of edges.

For a complete graph with nn vertices:

  • The number of vertices is V=nV = n.
  • The number of edges in a complete graph is E=n(n−1)2E = \frac{n(n-1)}{2} (for undirected) or E=n(n−1)E = n(n-1) (for directed). In both cases, the number of edges is E=Θ(n2)E = \Theta(n^2).

Substituting these values into the complexity formula:

Time Complexity=Θ(n⋅n2)=Θ(n3)\text{Time Complexity} = \Theta(n \cdot n^2) = \Theta(n^3)

Hence, the correct option is C.

Free practice · Your answers on this page are not saved.

Published
Report a correction
Keep exploringMore Shortest Paths (Dijkstra, Bellman-Ford) questions