GATE / CS ARCHIVE

GATE CSE 2006 / QUESTION 12

Unweighted shortest paths

Algorithms · Graph Algorithms · Full GATE CSE 2006 paper

GATE 2006, Q12 1 mark · MCQ
Report issue

Graph Algorithms

Question 12, GATE 2006: Which data structure lets the shortest-path method on an unweighted graph run in linear time, as the unweighted specialization of Dijkstra’s algorithm?
Options:
(A) Queue
(B) Stack
(C) Heap
(D) B-tree
Tap to enlarge
Your answer
Answer & solution

Answer: A (no official key was published)

1. All edges have equal unit cost, so increasing distance order is breadth-first order. A FIFO queue processes each vertex and scans each adjacency list once, in O(V+E) time.

2. Thus A; a priority heap is unnecessary.

3. Teaching check: In an unweighted graph, every discovered neighbor is exactly one hop farther than its predecessor. A FIFO queue keeps frontier layers in nondecreasing distance order, which is the priority rule Dijkstra needs here. With adjacency lists the total scan cost is the sum of degrees, O(V+E).

Original paper, page 2