Q. In the context of Dijkstra's algorithm, what does 'tentative distance' refer to?
-
A.
The final distance to the destination
-
B.
The distance calculated from the source to a node
-
C.
The distance to the nearest neighbor
-
D.
The distance that has been confirmed
Solution
The 'tentative distance' refers to the distance calculated from the source to a node, which may be updated as shorter paths are found.
Correct Answer:
B
— The distance calculated from the source to a node
Learn More →
Q. In which scenario is Dijkstra's algorithm most effective?
-
A.
When all edge weights are negative
-
B.
When edge weights are non-negative
-
C.
When the graph is unweighted
-
D.
When the graph is a tree
Solution
Dijkstra's algorithm is most effective when all edge weights are non-negative, as it relies on this property to ensure the shortest path is found.
Correct Answer:
B
— When edge weights are non-negative
Learn More →
Q. What is the output of Dijkstra's algorithm?
-
A.
The shortest path from the source to a single destination
-
B.
The shortest path from the source to all destinations
-
C.
The longest path in the graph
-
D.
The minimum spanning tree of the graph
Solution
The output of Dijkstra's algorithm is the shortest path from the source to all destinations in the graph.
Correct Answer:
B
— The shortest path from the source to all destinations
Learn More →
Q. What is the primary application of Dijkstra's algorithm?
-
A.
Finding the maximum element in an array
-
B.
Finding the shortest path in a graph
-
C.
Sorting an array
-
D.
Searching for an element in a linked list
Solution
Dijkstra's algorithm is primarily used for finding the shortest path from a source node to all other nodes in a weighted graph.
Correct Answer:
B
— Finding the shortest path in a graph
Learn More →
Q. What type of graph can Dijkstra's algorithm be applied to?
-
A.
Directed graphs only
-
B.
Undirected graphs only
-
C.
Both directed and undirected graphs
-
D.
Graphs with cycles only
Solution
Dijkstra's algorithm can be applied to both directed and undirected graphs as long as the edge weights are non-negative.
Correct Answer:
C
— Both directed and undirected graphs
Learn More →
Q. Which algorithm is a better choice than Dijkstra's for graphs with negative edge weights?
-
A.
A* Search Algorithm
-
B.
Bellman-Ford Algorithm
-
C.
Floyd-Warshall Algorithm
-
D.
Depth-First Search
Solution
The Bellman-Ford algorithm is a better choice than Dijkstra's for graphs with negative edge weights, as it can handle them correctly.
Correct Answer:
B
— Bellman-Ford Algorithm
Learn More →
Q. Which of the following is NOT an application of Dijkstra's algorithm?
-
A.
GPS navigation systems
-
B.
Network routing protocols
-
C.
Finding the minimum spanning tree
-
D.
Robot path planning
Solution
Finding the minimum spanning tree is not an application of Dijkstra's algorithm; it is typically solved using Prim's or Kruskal's algorithms.
Correct Answer:
C
— Finding the minimum spanning tree
Learn More →
Showing 1 to 7 of 7 (1 Pages)