|
|
|
|
|
by nostrademons
362 days ago
|
|
Another way I like to think about it is that every graph traversal can be represented as a white set of unknown nodes, a grey set of known but unvisited nodes, and a black set of visited nodes. The data structure used to represent the grey set defines the algorithm: DFS = queue BFS = stack Dijstra's = priority queue keyed by edge weight A* = priority queue with heuristic function Beam search = bounded priority queue with heuristic function Topological sort = priority queue keyed by number of unvisited inbound edges Copying garbage collector = pointer address Mark & sweep garbage collector = dirty bit on the object pointed to Generational garbage collector = multi-level grey set represented by the write barriers between each generation. |
|