|
|
|
|
|
by JohnKemeny
359 days ago
|
|
OP's point is that · BFS is priority queue with key h(n) + g(n), where h(n) = 0, g(n) = #edges · Dijkstra's is priority queue with key h(n) + g(n), where h(n) = 0, g(n) = sum over edges · A* is priority queue with key h(n) + g(n), where h(n) = heuristic(n), g(n) = sum over edges It's cute. |
|
This is the insight behind the decorate-sort-undecorate pattern; it's just heapsort, with a different key function allowing you to represent several different algorithms.