Created
January 21, 2016 02:07
-
-
Save blasten/5a5033e93e2f3e91df6b to your computer and use it in GitHub Desktop.
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
// Recursive depth first search | |
function RecursiveDFSTraversal(root, fn, fnArgs) { | |
if (!root) { | |
return; | |
} | |
fnArgs = fn(root, fnArgs); | |
for (var i = 0; fnArgs && i < root.children.length; i++) { | |
RecursiveDFSTraversal(root.children[i], fn, fnArgs); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment