Q. If a graph has 5 vertices and 10 edges, what is the maximum number of iterations Dijkstra's algorithm will perform?
Solution
Dijkstra's algorithm will perform at most V iterations, where V is the number of vertices. In this case, it will perform 5 iterations.
Correct Answer:
A
— 5
Learn More →
Q. In the context of Dijkstra's algorithm, what does the 'relaxation' process involve?
-
A.
Updating the priority queue.
-
B.
Calculating the shortest path.
-
C.
Updating the distance to a vertex.
-
D.
Removing a vertex from the graph.
Solution
Relaxation involves updating the distance to a vertex if a shorter path is found through another vertex.
Correct Answer:
C
— Updating the distance to a vertex.
Learn More →
Q. What is the primary purpose of the priority queue in Dijkstra's algorithm?
-
A.
To store all vertices.
-
B.
To keep track of visited vertices.
-
C.
To efficiently retrieve the next vertex with the smallest distance.
-
D.
To sort the edges.
Solution
The priority queue is used to efficiently retrieve the next vertex with the smallest distance estimate during the algorithm's execution.
Correct Answer:
C
— To efficiently retrieve the next vertex with the smallest distance.
Learn More →
Showing 1 to 3 of 3 (1 Pages)