Q. How does Dijkstra's algorithm update the tentative distances?
-
A.
By adding the edge weights to the current distances
-
B.
By multiplying the edge weights with the current distances
-
C.
By subtracting the edge weights from the current distances
-
D.
By averaging the edge weights
Solution
Dijkstra's algorithm updates the tentative distances by adding the edge weights to the current distance of the node.
Correct Answer:
A
— By adding the edge weights to the current distances
Learn More →
Q. What is the first step in Dijkstra's algorithm?
-
A.
Select the node with the smallest tentative distance
-
B.
Initialize all distances to infinity
-
C.
Mark all nodes as unvisited
-
D.
Add all edges to the priority queue
Solution
The first step is to initialize the distance to the source node as 0 and all other nodes as infinity.
Correct Answer:
B
— Initialize all distances to infinity
Learn More →
Showing 1 to 2 of 2 (1 Pages)