The GATE Grind

GATE 2013 CS (CS1) – Question 29

Algorithms · Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths · 1 mark · Multiple choice

What is Bellman–Ford’s running time on a complete graph with n vertices?

  1. $\Theta(n^2)$
  2. $\Theta(n^2\log n)$
  3. $\Theta(n^3)$
  4. $\Theta(n^3\log n)$

Practise this question in The GATE Grind →

Show answer and explanation

Correct answer: (C) $\Theta(n^3)$

Explanation

The standard algorithm relaxes all edges over n−1 passes, costing Θ(VE). A complete graph has Θ(n²) edges, so this becomes Θ(n·n²)=Θ(n³), C, for the standard full-pass worst-case bound.

More Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths questions

All Graph Algorithms: Traversals, Minimum Spanning Trees, Shortest Paths questions →