Q. In which scenario is Dijkstra's algorithm NOT applicable?
-
A.
When all edge weights are non-negative
-
B.
When there are negative edge weights
-
C.
When the graph is directed
-
D.
When the graph is undirected
Solution
Dijkstra's algorithm cannot handle graphs with negative edge weights.
Correct Answer:
B
— When there are negative edge weights
Learn More →
Q. What is the primary data structure used in Dijkstra's algorithm?
-
A.
Stack
-
B.
Queue
-
C.
Priority Queue
-
D.
Array
Solution
Dijkstra's algorithm primarily uses a priority queue to efficiently fetch the next vertex with the smallest distance.
Correct Answer:
C
— Priority Queue
Learn More →
Q. What is the space complexity of Dijkstra's algorithm when using an adjacency list?
-
A.
O(V)
-
B.
O(E)
-
C.
O(V + E)
-
D.
O(V^2)
Solution
The space complexity of Dijkstra's algorithm using an adjacency list is O(V + E), where V is the number of vertices and E is the number of edges.
Correct Answer:
C
— O(V + E)
Learn More →
Q. What is the time complexity of Dijkstra's algorithm using a priority queue?
-
A.
O(V^2)
-
B.
O(E + V log V)
-
C.
O(V log V)
-
D.
O(E log V)
Solution
Dijkstra's algorithm has a time complexity of O(E log V) when implemented with a priority queue.
Correct Answer:
D
— O(E log V)
Learn More →
Q. Which of the following is a real-world application of Dijkstra's algorithm?
-
A.
Finding the shortest path in a maze
-
B.
Calculating the minimum spanning tree
-
C.
Routing in computer networks
-
D.
Sorting a list of numbers
Solution
Dijkstra's algorithm is commonly used for routing in computer networks to find the shortest path between nodes.
Correct Answer:
C
— Routing in computer networks
Learn More →
Showing 1 to 5 of 5 (1 Pages)