Q. In Dijkstra's algorithm, how is the next node to process selected?
A.
By selecting the node with the highest degree
B.
By selecting the node with the lowest tentative distance
C.
By selecting the node that was added last
D.
By selecting a random node
Show solution
Solution
The next node to process in Dijkstra's algorithm is selected based on the lowest tentative distance, ensuring the shortest path is explored first.
Correct Answer:
B
— By selecting the node with the lowest tentative distance
Learn More →
Q. In Dijkstra's algorithm, what does the 'tentative distance' represent?
A.
The actual shortest distance found
B.
The estimated distance to the destination
C.
The distance from the source to the current node
D.
The maximum distance in the graph
Show solution
Solution
The 'tentative distance' represents the current best-known distance from the source node to the current node being processed.
Correct Answer:
C
— The distance from the source to the current node
Learn More →
Q. What happens if Dijkstra's algorithm is applied to a graph with negative weight edges?
A.
It will still find the shortest path.
B.
It may produce incorrect results.
C.
It will not terminate.
D.
It will find the longest path.
Show solution
Solution
Dijkstra's algorithm may produce incorrect results if applied to graphs with negative weight edges, as it assumes that once a node's shortest path is found, it cannot be improved.
Correct Answer:
B
— It may produce incorrect results.
Learn More →
Q. What is the initial value of the tentative distance for the source node in Dijkstra's algorithm?
A.
Infinity
B.
0
C.
1
D.
The weight of the first edge
Show solution
Solution
The initial value of the tentative distance for the source node is set to 0, as it is the starting point.
Correct Answer:
B
— 0
Learn More →
Q. What is the main limitation of Dijkstra's algorithm?
A.
It cannot find paths in directed graphs.
B.
It cannot handle graphs with cycles.
C.
It cannot handle negative weight edges.
D.
It is not efficient for large graphs.
Show solution
Solution
The main limitation of Dijkstra's algorithm is that it cannot handle graphs with negative weight edges, as it may lead to incorrect path calculations.
Correct Answer:
C
— It cannot handle negative weight edges.
Learn More →
Q. What is the primary purpose of Dijkstra's algorithm?
A.
To find the shortest path in a weighted graph
B.
To sort an array
C.
To search for an element in a list
D.
To traverse a binary tree
Show solution
Solution
Dijkstra's algorithm is designed to find the shortest path from a source node to all other nodes in a weighted graph.
Correct Answer:
A
— To find the shortest path in a weighted graph
Learn More →
Q. What is the time complexity of Dijkstra's algorithm when implemented with a binary heap?
A.
O(V^2)
B.
O(E log V)
C.
O(V log V)
D.
O(E + V)
Show solution
Solution
When using a binary heap, the time complexity of Dijkstra's algorithm is O(E log V), where E is the number of edges and V is the number of vertices.
Correct Answer:
B
— O(E log V)
Learn More →
Q. Which data structure is commonly used to implement Dijkstra's algorithm?
A.
Stack
B.
Queue
C.
Priority Queue
D.
Array
Show solution
Solution
A priority queue is used in Dijkstra's algorithm to efficiently retrieve the next node with the smallest tentative distance.
Correct Answer:
C
— Priority Queue
Learn More →
Q. Which of the following algorithms can be used instead of Dijkstra's algorithm for graphs with negative weights?
A.
A* Search
B.
Bellman-Ford Algorithm
C.
Floyd-Warshall Algorithm
D.
Depth-First Search
Show solution
Solution
The Bellman-Ford algorithm can be used for graphs with negative weights, as it can handle such cases correctly.
Correct Answer:
B
— Bellman-Ford Algorithm
Learn More →
Q. Which of the following statements is true about Dijkstra's algorithm?
A.
It can handle negative weight edges.
B.
It always finds the shortest path.
C.
It can be used for directed graphs only.
D.
It requires a complete graph.
Show solution
Solution
Dijkstra's algorithm always finds the shortest path in graphs with non-negative weights.
Correct Answer:
B
— It always finds the shortest path.
Learn More →
Showing 1 to 10 of 10 (1 Pages)