Created
August 14, 2014 20:24
-
-
Save mlconnor/7e97ca78ac86b93ded90 to your computer and use it in GitHub Desktop.
depth first search vs breadth first search
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
list nodes_to_visit = {root}; | |
while( nodes_to_visit isn't empty ) { | |
currentnode = nodes_to_visit.first(); | |
nodes_to_visit.prepend( currentnode.children ); | |
//do something | |
} | |
BFS: | |
list nodes_to_visit = {root}; | |
while( nodes_to_visit isn't empty ) { | |
currentnode = nodes_to_visit.first(); | |
nodes_to_visit.append( currentnode.children ); | |
//do something | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment