Data Structures & Algorithms Multiple Choice Questions on “Bellman-Ford Algorithm”.
1. The Bellmann Ford algorithm returns _______ value. Answer: a 2. Bellmann ford algorithm provides solution for ____________ problems. Answer: d 3. Bellmann Ford algorithm is used to indicate whether the graph has negative weight cycles or not. 4. How many solution/solutions are available for a graph having negative weight cycle? Answer: c 5. What is the running time of Bellmann Ford Algorithm? Answer: d 6. How many times the for loop in the Bellmann Ford Algorithm gets executed? Answer: b 7. Dijikstra’s Algorithm is more efficient than Bellmann Ford Algorithm. 8. Identify the correct Bellmann Ford Algorithm. b) c) d) Answer: a 9. What is the basic principle behind Bellmann Ford Algorithm? Answer: d 10. Bellmann Ford Algorithm can be applied for _____________ Answer: c 11. Bellmann Ford algorithm was first proposed by ________ Answer: b 12. Consider the following graph. What is the minimum cost to travel from node A to node C? Answer: b 13. In the given graph, identify the path that has minimum cost to travel from node a to node f. Answer: d 14. Bellmann Ford Algorithm is an example for ____________ Answer: a 15. A graph is said to have a negative weight cycle when? Answer: c
a) Boolean
b) Integer
c) String
d) Double
Clarification: The Bellmann Ford algorithm returns Boolean value whether there is a negative weight cycle that is reachable from the source.
a) All pair shortest path
b) Sorting
c) Network flow
d) Single source shortest path
Clarification: Bellmann ford algorithm is used for finding solutions for single source shortest path problems. If the graph has no negative cycles that are reachable from the source then the algorithm produces the shortest paths and their weights.
a) True
b) False
Answer: a
Clarification: Bellmann Ford algorithm returns true if the graph does not have any negative weight cycles and returns false when the graph has negative weight cycles.
a) One solution
b) Two solutions
c) No solution
d) Infinite solutions
Clarification: If the graph has any negative weight cycle then the algorithm indicates that no solution exists for that graph.
a) O(V)
b) O(V2)
c) O(ElogV)
d) O(VE)
View Answer
Clarification: Bellmann Ford algorithm runs in time O(VE), since the initialization takes O(V) for each of V-1 passes and the for loop in the algorithm takes O(E) time. Hence the total time taken by the algorithm is O(VE).
a) V times
b) V-1
c) E
d) E-1
Clarification: The for loop in the Bellmann Ford Algorithm gets executed for V-1 times. After making V-1 passes, the algorithm checks for a negative weight cycle and returns appropriate boolean value.
a) True
b) False
Answer: a
Clarification: The running time of Bellmann Ford Algorithm is O(VE) whereas Dijikstra’s Algorithm has running time of only O(V2).
a)for i=1 to V[g]-1
do for each edge (u,v) in E[g]
do Relax(u,v,w)
for each edge (u,v) in E[g]
do if d[v]>d[u]+w(u,v)
then return False
return True
for i=1 to V[g]-1
for each edge (u,v) in E[g]
do if d[v]>d[u]+w(u,v)
then return False
return True
for i=1 to V[g]-1
do for each edge (u,v) in E[g]
do Relax(u,v,w)
for each edge (u,v) in E[g]
do if d[v]<d[u]+w(u,v)
then return true
return True
for i=1 to V[g]-1
do for each edge (u,v) in E[g]
do Relax(u,v,w)
return True
Clarification: After initialization, the algorithm makes v-1 passes over the edges of the graph. Each pass is one iteration of the for loop and consists of relaxing each edge of the graph once. Then it checks for the negative weight cycle and returns an appropriate Boolean value.
a) Interpolation
b) Extrapolation
c) Regression
d) Relaxation
Clarification: Relaxation methods which are also called as iterative methods in which an approximation to the correct distance is replaced progressively by more accurate values till an optimum solution is found.
a) Undirected and weighted graphs
b) Undirected and unweighted graphs
c) Directed and weighted graphs
d) All directed graphs
Clarification: Bellmann Ford Algorithm can be applied for all directed and weighted graphs. The weight function in the graph may either be positive or negative.
a) Richard Bellmann
b) Alfonso Shimbe
c) Lester Ford Jr
d) Edward F. Moore
Clarification: Alfonso Shimbe proposed Bellmann Ford algorithm in the year 1955. Later it was published by Richard Bellmann in 1957 and Lester Ford Jr in the year 1956. Hence it is called Bellmann Ford Algorithm.
a) 5
b) 2
c) 1
d) 3
View Answer
Clarification: The minimum cost to travel from node A to node C is 2.
A-D, cost=1
D-B, cost=-2
B-C, cost=3
Hence the total cost is 2.
a) a-b-c-f
b) a-d-e-f
c) a-d-b-c-f
d) a-d-b-c-e-f
Clarification: The minimum cost taken by the path a-d-b-c-e-f is 4.
a-d, cost=2
d-b, cost=-2
b-c, cost=1
c-e, cost= 2
e-f, cost=1
Hence the total cost is 4.
a) Dynamic Programming
b) Greedy Algorithms
c) Linear Programming
d) Branch and Bound
Clarification: In Bellmann Ford Algorithm the shortest paths are calculated in bottom up manner which is similar to other dynamic programming problems.
a) The graph has 1 negative weighted edge
b) The graph has a cycle
c) The total weight of the graph is negative
d) The graph has 1 or more negative weighted edges
Clarification: When the total weight of the graph sums up to a negative number then the graph is said to have a negative weight cycle. Bellmann Ford Algorithm provides no solution for such graphs.