News for hackers. Stuff that matters.
Re:Ask HN: What's your favorite elegant/beautiful algorithm? by yellowflash on Wednesday October 17, 2018 @08:28AM (#18238282)
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.

There are no comments on this comment yet.