GATE / CS ARCHIVE

GATE CSE 2013 / QUESTION 19

Bellman-Ford on a complete graph

Algorithms · Graph Algorithms · Full GATE CSE 2013 paper

GATE 2013, Q19 1 mark · MCQ
Report issue

Graph Algorithms

Question 19, GATE 2013: What is standard Bellman–Ford complexity on a complete n-vertex graph? AΘ(n²), BΘ(n²log n), CΘ(n³), DΘ(n³log n).
Tap to enlarge
Your answer
Answer & solution

Official answer: C

The standard Bellman-Ford algorithm performs up to n−1 full edge-relaxation passes. A complete graph has Θ(n²) edges, yielding Θ(n³) time, C, for the usual worst-case/full-pass algorithm.

One relaxation pass examines all edges. The standard algorithm allows n−1 passes because a simple shortest path can use up to n−1 edges. A complete directed graph has n(n−1) edges; an undirected one has n(n−1)/2, both Θ(n²). Multiplying by Θ(n) passes gives Θ(n³). Early termination may improve a particular instance, but does not change the stated standard worst-case/full-pass bound.

Original paper, page 5 · Answer key