CHAPTER 24
Total 10 marks
1. The Bellman-Ford algorithm returns a boolean value. What does the Boolean value indicate?
(1 mark)
Answer
The Bellman-Ford algorithm returns a boolean value indicating whether or not there is a
negative-weight cycle that is reachable from the source.
2. What is the running time of Dijkstra’s shortest-path algorithm if:
(i) Binary heap is implemented
(ii) Fibonacci heap is implemented
(1 mark)
Answer
(i) O(E lg V)
(ii) O(V lg V + E).
3. Given a weighted directed graph G= (V, E, w, s), where the source is s, if G has a negativeweight cycle somewhere, then the Bellman-Ford algorithm will necessarily compute an
incorrect result for some δ(s, v). (1 mark)
(i) True
(ii) False
Answer
(ii) False. The negative-weight cycle has to be reachable from s.
4. What do you understand by “relaxing an edge”? Give an example. (1 mark)
Answer (The algorithm is optional)
The process of relaxing an edge (u , v) consists of testing whether we can improve the shortest
path to v found so far by going through u and, if so, updating v.d and v.π. A relaxation step1
may decrease the value of the shortest-path estimate v. d and update v’s predecessor attribute
v.π.
5. Consider the following graph. If we run Dijkstra’s algorithm on it. What’s the order of adding
to S?
(2 mark)
(i) s , y , z ,x
(ii) s, x, y, z
(iii) s, y, x, z
(iv) s, x, z, y
Answer
(i) s , y , z ,x
(iii) s, y, x, z
Any one correct answer is fine as Djkstra’s algorithm will only take one path.
6. Consider the given equations:
x1 − x2 ≤ 5
x1 − x3 ≤ 6
x2 − x4 ≤ −1
x3 − x4 ≤ −2
x4 − x1 ≤ −3
if x = (0, -4, -5, -3) is a set of feasible solution. Then, what can be another set of feasible
solution? (1 mark)
(i) x = (5, 1, 0, 2)
(ii) x = (5, 2, 5, 3)
(iii) x = (6, 1, 3, 2)
(iv) x = (6, 2, 0, 3)
Answer
(i) x = (5, 1, 0, 2) as d= 5 because {solution} + 5
7. Run DAG-SHORTEST-PATHS (G, w, s) on the following directed acyclic graph. Show all the
steps.
( 3 marks)
Answer
Chapter 25
Ans 1: True
Ans 2: O (V^3), because there are three nested for loops in algorithm.
Ans 3: Intermediate
Ans 4: O (V^2LgV + VE)
Ans 5: Reweighting an edge means replace the negative weights with positive weights in that
way so that it does not changes the original shortest paths between all the vertices of given
graph.
Ans 6 : True
Ans 7:
© Copyright 2026 Paperzz