Dijkstra's Algorithm Problems
- 14Unfamiliar
- 0Learning
- 0Familiar
- 0Mastered
What is a primary issue with Dijkstra's algorithm that A* aims to resolve?
What is a primary issue with Dijkstra's algorithm that A* aims to resolve?
14 questions
- 1
What is a primary issue with Dijkstra's algorithm that A* aims to resolve?
- A
It often explores paths that move away from the goal, regardless of direction.
- B
It only works efficiently on graphs with uniform edge weights.
- C
It prioritizes paths based on estimated remaining distance to the goal.
- D
It fails to find the shortest path in dense network structures like cities.
Correct answer
AIt often explores paths that move away from the goal, regardless of direction.
Explanation
Dijkstra's algorithm follows the path currently shortest and does not pay attention to the direction towards the goal, which can lead it to explore paths that diverge from the optimal route to the destination. A* addresses this by incorporating a heuristic that considers the direction.
- A
- 2
In what scenario does Dijkstra's algorithm become particularly inefficient due to its search pattern?
- A
When the graph is extremely sparse, with few connections between nodes.
- B
When all edge weights are identical, leading to a simple flood fill pattern.
- C
When the graph represents a road network with mostly unpaved country roads.
- D
When it explores many short paths in directions opposite to the end goal.
Correct answer
BWhen all edge weights are identical, leading to a simple flood fill pattern.
Explanation
If all weights are uniform, Dijkstra's algorithm performs a 'flood fill' from the start node, expanding in all directions, which is inefficient if the goal is directly in one specific direction. A* improves this by guiding the search.
- A
- 3
How does A* algorithm fundamentally extend Dijkstra's algorithm?
- A
A* removes the need for a priority queue, speeding up the process.
- B
A* changes the core shortest path calculation logic entirely.
- C
A* adds a heuristic to prioritize nodes that are closer to the end goal.
- D
A* introduces a mechanism to dynamically change edge weights during search.
Correct answer
CA* adds a heuristic to prioritize nodes that are closer to the end goal.
Explanation
A* is described as a 'small extension to Dijkstra' that 'builds in a heuristic' to guide the search towards the goal. This heuristic helps prioritize nodes that are likely to lead to the goal faster.
- A
- 4
What is a common and reasonable heuristic used in A* for pathfinding on a map?
- A
A random value assigned to each node to ensure exploration.
- B
The literal Euclidean distance from the current node to the end goal.
- C
The sum of all edge weights encountered so far in the path.
- D
The number of nodes visited since the start node.
Correct answer
BThe literal Euclidean distance from the current node to the end goal.
Explanation
A 'pretty reasonable heuristic to come up with will be literal Euclidean distance of how far we have to go' from the current node to the end goal, providing a direct estimation of remaining distance.
- A
- 5
Which of these is a critical property for a heuristic to ensure A* works optimally?
- A
The heuristic should be identical for all nodes in the entire graph.
- B
The heuristic must consistently overestimate the distance to the goal.
- C
The heuristic must be consistent and not overestimate the remaining distance.
- D
The heuristic should only consider the direct path cost, not remaining distance.
Correct answer
CThe heuristic must be consistent and not overestimate the remaining distance.
Explanation
For A* to work well, the heuristic must have a 'consistent metric' and 'not overestimate how far you've got to go'. These properties are crucial for optimality guarantees.
- A
- 6
How does the ordering of nodes in the priority queue differ between Dijkstra and A*?
- A
Dijkstra orders by path distance, while A* orders by remaining distance to goal.
- B
A* uses no ordering; it simply processes nodes in the order they are discovered.
- C
A* orders by path distance, while Dijkstra orders by combined cost and heuristic.
- D
Dijkstra orders by current distance from start, A* orders by (distance + heuristic).
Correct answer
DDijkstra orders by current distance from start, A* orders by (distance + heuristic).
Explanation
In Dijkstra, the queue is ordered by the 'current distance from the start to these nodes'. In A*, the order is determined by 'the distance of the path plus how far they have to go', which is the combined cost of 'g' (path cost) and 'h' (heuristic).
- A
- 7
What happens to a node with a high heuristic cost in A*'s priority queue?
- A
It is removed from the queue entirely, as it is deemed inefficient.
- B
It is re-evaluated with a different heuristic function.
- C
It is prioritized and expanded immediately, regardless of path cost.
- D
It receives a higher combined weight, moving it further down the queue.
Correct answer
DIt receives a higher combined weight, moving it further down the queue.
Explanation
If something has a 'long way to go', it's going to receive a higher weight and be further down the queue and expanded later. This is because a high heuristic cost increases the combined cost (g+h).
- A
- 8
When considering if a path to node A is better via node B in A*, which cost is used for comparison?
- A
The heuristic cost from A to the goal is used for comparison.
- B
The combined cost (path + heuristic) is used for path comparison.
- C
A weighted average of the heuristic and path costs is calculated.
- D
The actual path cost to A via B is used, ignoring the heuristic for comparison.
Correct answer
DThe actual path cost to A via B is used, ignoring the heuristic for comparison.
Explanation
When deciding 'whether the path to A better via B we don't care about this heuristic, we only care about the actual cost of it, the path to A'. This means only the 'g' cost (distance from start) is used for path improvement.
- A
- 9
What is the 'g' cost function in the context of A* algorithm?
- A
It represents the actual distance from the start node to the current node.
- B
It represents the initial cost assigned to all unvisited nodes.
- C
It represents the estimated remaining distance from the current node to the goal.
- D
It represents the total combined cost of the path to the current node plus heuristic.
Correct answer
AIt represents the actual distance from the start node to the current node.
Explanation
The 'g' cost function is defined as 'the distance to a current node', representing the actual accumulated path cost from the start node to that specific node.
- A
- 10
What does the combined cost (g + h) represent in A* algorithm?
- A
Only the actual distance from the start to the current node.
- B
The average of the path cost and the heuristic estimated remaining cost.
- C
Only the estimated distance from the current node to the goal.
- D
The sum of the actual path cost and the heuristic estimated remaining cost.
Correct answer
DThe sum of the actual path cost and the heuristic estimated remaining cost.
Explanation
The combined cost is defined as 'the distance of the path plus how far they have to go', meaning it is the sum of the 'g' cost (actual path cost) and the 'h' cost (heuristic estimate to goal).
- A
- 11
Why does A* often expand fewer nodes compared to Dijkstra's algorithm?
- A
A* ignores certain paths that Dijkstra would explore, even if they are short.
- B
A* uses a simpler data structure, requiring less memory and computation.
- C
A* prioritizes nodes that are likely to be on the optimal path to the goal.
- D
A* always finds a different, shorter path than what Dijkstra would find.
Correct answer
CA* prioritizes nodes that are likely to be on the optimal path to the goal.
Explanation
A* expands fewer nodes because it 'prioritize[s] nodes that are going roughly in the right direction' due to its heuristic, avoiding unnecessary exploration of paths leading away from the goal.
- A
- 12
What is the correct stopping criterion for both Dijkstra's and A* algorithms?
- A
When the goal node is first discovered and added to the priority queue.
- B
When the algorithm has explored all possible paths from the start node.
- C
When a predefined maximum number of nodes has been expanded.
- D
When the goal node bubbles to the top of the priority queue for expansion.
Correct answer
DWhen the goal node bubbles to the top of the priority queue for expansion.
Explanation
The actual stopping criterion for both Dijkstra and A* is 'when your goal node gets to the top of your priority queue' because only then can one be certain that the shortest path to it has been found.
- A
- 13
Why is it important for the goal node to reach the top of the priority queue before stopping?
- A
To confirm that the heuristic function used was perfectly accurate.
- B
This condition prevents the algorithm from running indefinitely.
- C
To ensure that all other potential goals have been thoroughly explored first.
- D
Because shorter paths to the goal might still be discovered through other nodes.
Correct answer
DBecause shorter paths to the goal might still be discovered through other nodes.
Explanation
It's crucial to wait until the goal node 'bubbles to the top of our priority queue to be able to know for sure that we've got the shortest path' because there could be 'super-sneaky and really quick' paths from other nodes that might be found later.
- A
- 14
How do modern sat-nav systems likely handle complex, large-scale pathfinding challenges?
- A
They rely solely on basic A* implementations for real-time calculations.
- B
They only compute paths for very short distances to avoid system overload.
- C
They request the user to manually input preferred routes for efficiency.
- D
They precompute common routes and hardcode known optimal segments.
Correct answer
DThey precompute common routes and hardcode known optimal segments.
Explanation
It is suggested that sat-navs 'precompute some of these things' and 'hard code some of it' for common routes (e.g., Nottingham to London via M1) due to the unrealistic expectation of fully computing vast distances in real-time.
- A

Ask anything
We've read this whole study set, so questions about it get the best answers.