GATE / CS ARCHIVE

GATE CSE 2005 / QUESTION 38

Dijkstra with a binary heap

Algorithms · Graph Algorithms · Full GATE CSE 2005 paper

GATE 2005, Q38 2 marks · MCQ
Report issue

Graph Algorithms

Question 38, GATE 2005: Dijkstra on positive-weight undirected G(V, E), using adjacency lists and a binary heap, has standard bound: A O(V²); B O(E+V log V); C O(V log V); D O((E+V)log V).
Tap to enlarge
Your answer
Answer & solution

Answer: D (no official key was published)

Using adjacency lists, up to V extract-min operations and O(E) decrease-key operations each cost O(log V) with a binary heap. Including initialization gives O((E+V)log V), D. The O(E+V log V) bound requires different amortized heap operations, such as a Fibonacci heap, not a standard binary heap.

Dijkstra extracts each vertex once and may relax each edge. A binary heap takes logarithmic time for extract-min and decrease-key, producing V log V plus E log V. The sum is O((V+E)log V). The tempting E+V log V bound uses an amortized heap with cheaper decrease-key, not the specified ordinary binary heap. Positive weights ensure the settled-distance greedy step is valid.

Original paper, page 5