You are on page 1of 1

Dijkstra's algorithm is an algorithm for finidng the shortest path between nodes in

a graph. This algorithm is best used in directed graphs with non-negative weights.
The algorithm uses these weights to nevigate the paths and locate the shortest path
to the desired goal. Early implementations of this algorithm were O(V^2) time,
where V is the number of nodes in the graph. Modifications to the original
algorithm have been made, using newer data structures, to make the algorithm
O(E+VlogV), where E is the number of edges. Additionally, modifications to the way
the algorithm weighs path choices have been made and used to implement new
algorithms. The A* algorithm is widely used for pathfinding and graph traversal due
to its great performance and accuracy in finding the desired goal. This algorithm
is an extension of Dijkstra's algorithm; the key difference being that A* uses
heuristics to guide the search. It can be said that Dijkstra's algorithm is
actually a special case of A* where h(n) = 0 for all nodes. These algorithms are
known as partially greedy because they implement the best aspects of greedy
algorithms and best-search algorithms.
With that being said, algorithms such as Prim's and Kruskal's algorithms also have
merit for generating minnimum spanning trees for graph searching. These algorithms,
unlike Dijkstra's and A*, are greedy best-first search algorithms that are used to
pathfind but not necessarily minimum-pathfind. These algorithms are focused on
finding the connection between the start and goal nodes without concern if the path
is actually the shortest available path. This is very different from Dijkstra's,
and therefore A*, because these algorithms are specifically for finding the minimum
A famous problem that uses a pathfinding algorithm is the Travelling Salesman
Problem (TSP), which is NP-hard and the exact algorithmic solutions come to around
O(n!). An approximate solution to this problem, which is not in exponential time,
is known as the Nearest Neighbor algorithm. This algorithm is a greedy algorithm,
like Prim's and Kruskal's algorithms, and it quickly yields an effectively short
route by letting the travelling salesman choose the nearest unvisited city as his
next move. This algorithm is accurate on average and yields about 25% greater than
the absolute shortest path. This is also similar to Prim's and Kruskal's in that
the paths are not guaranteed to be the shortest. This algorithm does use a
heuristic, like A*, known as a constructive heuristic.