5 ms·
Actually it's pretty elegant by itself, Consider this all traversals are same, val someDS; while(!someDS.isEmpty()){ addChildren(someDS.pop()) } Now rep
by yellowflash 8y ago
Actually it's pretty elegant by itself, Consider this all traversals are same,
val someDS;
while(!someDS.isEmpty()){
addChildren(someDS.pop())
}
Now replace, someDs with
Queue -> BFS
Stack -> DFS
Priority Queue, with priority of distance so far -> Dijkstra.
Priority Queue, with distance + heuristic -> A*
Its beautiful.