Q. In a graph, if all edges have the same weight, which algorithm can be used to find the shortest path?
-
A.
Dijkstra's algorithm
-
B.
Breadth-First Search (BFS)
-
C.
Depth-First Search (DFS)
-
D.
A* Search
Solution
When all edges have the same weight, Breadth-First Search (BFS) can be used to find the shortest path.
Correct Answer:
B
— Breadth-First Search (BFS)
Learn More →
Q. Which of the following is NOT a characteristic of Dijkstra's algorithm?
-
A.
It uses a greedy approach
-
B.
It guarantees the shortest path
-
C.
It can be used for negative weights
-
D.
It requires a priority queue
Solution
Dijkstra's algorithm cannot be used for graphs with negative weights, which is a key characteristic.
Correct Answer:
C
— It can be used for negative weights
Learn More →
Q. Which of the following scenarios is Dijkstra's algorithm best suited for?
-
A.
Finding the shortest path in a road network
-
B.
Sorting a list of numbers
-
C.
Searching for an element in a binary search tree
-
D.
Finding the maximum flow in a network
Solution
Dijkstra's algorithm is particularly effective for finding the shortest path in road networks where edges have non-negative weights.
Correct Answer:
A
— Finding the shortest path in a road network
Learn More →
Showing 1 to 3 of 3 (1 Pages)