Dijkstra and A* Flashcards
Dijkstra purpose
Finds the shortest path from one node to all others
Dijkstra characteristics
Works with non negative weights
Needs graph, initial node, colection with visited nodes, collection of nodes to visit
Dijkstra node info
costSoFar -> minimum cost from initial node to current node
bestParent -> node from wich we get the costSoFar
Does dijkstra use an heuristic?
No
Dijkstra performance
O(N*b)
b -> average number of connections per node
Version of algo to target
O(b^(1+(C/£))
C/£ -> expected depth of the solution
A* evaluation function
F(n) = g(n) + h(n)
g(n) -> cost of the given solution so far
h(n) -> heuristic function - estimated best cost from n to the solution
A* node info
costSoFar -> minimum cost from initial node to current node
bestParent -> node from wich we get the costSoFar
heuristic(targetNode) -> prediction of the cost from the node to the target node
How does A* solve ties?
Depends on how we organize the open list
How do we garantee that A* always finds the optimal path?
We can achieve that as long as the heuristic gives lower values that the true value
What is a consistent heuristic? Does A* need to always use consistent heuristics to find the optimal path?
It defends that its always better to go straight to a node thatn to go around
No
What is an admissible heuristic? Does A* need to always use admissible heuristics?
Heuristics that never overestimate the real remaining cost to reach the goal
No
What is the main difference between Dijkstra and A*?
In A* we use an heuristic to predict the cost from the current node to the goal node
Is there other algorithm that can expand fewer nodes and still ensure optimality than A*?
No
When is it ok to use non-admissible heuristics?
When the heuristic error is low
Why shold’t we use complex heuristic calculations?
Because it can easily dominate the pathfinding algorithm