Created
June 4, 2012 05:27
-
-
Save Hydrotoast/2866520 to your computer and use it in GitHub Desktop.
BST Recursive Pseudocode
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
def insertNode(root, newNode, data): | |
if root is null: | |
root = newNode | |
root.data = data | |
elif data < root.left: | |
root.left = insertNode(root.left, newNode, data); | |
else: | |
root.right = insertNode(root.right, newNode, data); | |
return root | |
def traverseNode(root, array, counter): | |
if root is null: | |
return; | |
traverseNode(root.left, array, counter) | |
array[counter] = root.data | |
traverseNode(root.right, array, counter) | |
return |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment