Q. If a graph has negative weight edges, which algorithm can be used instead of Dijkstra's?
-
A.
Prim's algorithm
-
B.
Kruskal's algorithm
-
C.
Bellman-Ford algorithm
-
D.
A* algorithm
Solution
The Bellman-Ford algorithm can handle graphs with negative weight edges, unlike Dijkstra's algorithm.
Correct Answer:
C
— Bellman-Ford algorithm
Learn More →
Q. In a weighted graph, if all edge weights are equal, which algorithm can be used to find the shortest path?
-
A.
Dijkstra's algorithm
-
B.
Breadth-First Search
-
C.
Depth-First Search
-
D.
A* algorithm
Solution
If all edge weights are equal, Dijkstra's algorithm is still applicable, but Breadth-First Search (BFS) can also be used to find the shortest path.
Correct Answer:
B
— Breadth-First Search
Learn More →
Q. What is the main advantage of using Dijkstra's algorithm over brute-force methods?
-
A.
It is simpler to implement
-
B.
It guarantees the shortest path in polynomial time
-
C.
It can handle larger graphs
-
D.
It uses less memory
Solution
Dijkstra's algorithm is more efficient than brute-force methods, as it guarantees finding the shortest path in polynomial time.
Correct Answer:
B
— It guarantees the shortest path in polynomial time
Learn More →
Showing 1 to 3 of 3 (1 Pages)