The shortest distance solution is an example of a greedy algorithm.
That is, at each step of the solution, we picked the smallest
Another problem that can be solved with a greedy algorithm: minimum cost spanning tree.
Given a weighted graph, find a subset of the edges that forms a tree and find one that has the minimum total weight (or cost).
When is a graph a tree?
- Number of vertices = N
- Number of edges = N-1
- No cycles