Created
May 29, 2017 05:28
-
-
Save vaidehijoshi/df7b4fbe8bb5fff19b977d3050fe61b9 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function preorderSearch(node) { | |
// Check that a node exists. | |
if (node === null) { | |
return; | |
} | |
// Print the data of the node. | |
console.log(node.data); | |
// Pass in a reference to the left child node to preorderSearch. | |
// Then, pass reference to the right child node to preorderSearch. | |
preorderSearch(node.left); | |
preorderSearch(node.right); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment