iterating through children backwards, so ‘left-most’ children are visited first
bfsRecursive assumes no cycles, since it doesn’t reference a ‘visited’ set
Dijkstra’s Algorithm and A-Star
Both Dijkstra’s and A-Star are algorithms for finding shortest paths and not just traversal algorithms.
We assume we have a PriorityQueue class that returns the value with the SMALLEST dist[n]
dijkstras returns the distance of all nodes from their source node and their paths
A Star is an ‘informed search algorithm’ and requires a ‘heuristic’ function that returns an estimated cost of the cheapest path from the current node to the end node.
In other implementations, gScore(n) denotes the known cost from the start to n, and fScore(n) is equal to the gScore(n) + h(n)
fScore is only used to determine which node to expand next from the prioQueue.
The heuristic function must satisfy: h(x) ≤ dist(x, y) + h(y) to be monotone or consistent.
Intuitively, this means the heuristic cannot overestimate the cost of x (to the goal) compared to the estimated cost of y + the actual distance between x and y.
When a heuristic is consistent, you’re guaranteed to find the optimal path and no node will be processed more than once.
Greedy Algorithms
Greedy algorithms build up a solution piece by piece, always choosing the next
piece that offers the most obvious and immediate benefit