Q. In which scenario would you prefer Dijkstra's algorithm over the Bellman-Ford algorithm?
-
A.
When the graph has negative weight edges
-
B.
When the graph is dense
-
C.
When the graph has non-negative weights
-
D.
When you need to find all pairs shortest paths
Solution
Dijkstra's algorithm is preferred when the graph has non-negative weights, as it is more efficient than Bellman-Ford in such cases.
Correct Answer:
C
— When the graph has non-negative weights
Learn More →
Q. What is the main advantage of using Dijkstra's algorithm in network routing?
-
A.
It guarantees the shortest path
-
B.
It is easy to implement
-
C.
It works with any type of graph
-
D.
It can handle dynamic changes in the graph
Solution
The main advantage of Dijkstra's algorithm in network routing is that it guarantees finding the shortest path in a weighted graph.
Correct Answer:
A
— It guarantees the shortest path
Learn More →
Q. Which data structure can be used to represent a graph for Dijkstra's algorithm?
-
A.
Array
-
B.
Linked List
-
C.
Adjacency Matrix
-
D.
All of the above
Solution
Dijkstra's algorithm can be implemented using various data structures to represent a graph, including arrays, linked lists, and adjacency matrices.
Correct Answer:
D
— All of the above
Learn More →
Showing 1 to 3 of 3 (1 Pages)