Shortest Path · Algorithms
22 questions · asked in 17 of 27 years (2000–2026)
MCQ 21 · NAT 11-mark 12 · 2-mark 10
2000Questions per year2026
Questions 21–22 of 22
Let G = (V,E) be an undirected graph with a sub-graph G1 = (V1,E1), Weight are assigned to edges of G as follows
A single-source shortest path algorithm is executed on the weighted graph (V,E,w) with an arbitrary vertex v1 of V1 as the source. Which of the following can always be inferred from the path costs computed?
A single-source shortest path algorithm is executed on the weighted graph (V,E,w) with an arbitrary vertex v1 of V1 as the source. Which of the following can always be inferred from the path costs computed?
Answer: (B)
The edges of weight 0 are exactly the edges of , and every other edge has weight 1. So a path from has cost 0 only if all its edges are in , that is, it stays inside .
So the cost to a vertex is 0 exactly when can be reached from using only edges of .
- If all vertices of get cost 0, then each is reachable from inside , so is connected.
- If some vertex of gets a cost above 0, it cannot be reached from inside , so is not connected.
So the costs tell us whether is connected.
Other options: the cost counts only weight-1 edges, not all edges on the path, so A cannot be inferred. A connected need not be a clique (a path graph is connected), and it need not be a tree (it may have cycles). The costs cannot tell C or D.
Answer: (B)
So the cost to a vertex is 0 exactly when can be reached from using only edges of .
- If all vertices of get cost 0, then each is reachable from inside , so is connected.
- If some vertex of gets a cost above 0, it cannot be reached from inside , so is not connected.
So the costs tell us whether is connected.
Other options: the cost counts only weight-1 edges, not all edges on the path, so A cannot be inferred. A connected need not be a clique (a path graph is connected), and it need not be a tree (it may have cycles). The costs cannot tell C or D.
Answer: (B)
Consider the undirected unweighted graph G. Let a breadth-first traversal of G be done starting from a node r . Let d(r,u) and d(r,v) be the lengths of the shortest paths form r to u and v respectively in G. If u is visited before v during the breadth-first traversal, which of the following statements is correct ?
Answer: (B)
BFS uses a queue. It visits all vertices at distance 0 from , then all at distance 1, then distance 2, and so on. So vertices are visited in non-decreasing order of their shortest distance from .
If is visited before , there are 2 cases:
1. is nearer to , so .
2. and are at the same distance, and BFS happened to pick first, so .
Together, . Option A is not always true because of case 2, and option C would mean is nearer, which BFS never allows.
Answer: (B)
If is visited before , there are 2 cases:
1. is nearer to , so .
2. and are at the same distance, and BFS happened to pick first, so .
Together, . Option A is not always true because of case 2, and option C would mean is nearer, which BFS never allows.
Answer: (B)
Keep practising