Created
April 12, 2021 16:38
-
-
Save ButlerFuqua/e24559da781a1f6527c7499e1a09331b 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
BSTInsert(tree, node) { | |
if (tree->root is null) | |
tree->root = node | |
node->left = null | |
node->right = null | |
else | |
cur = tree->root | |
while (cur is not null) | |
if (node->key < cur->key) | |
if (cur->left is null) | |
cur->left = node | |
cur = null | |
else | |
cur = cur->left | |
else | |
if (cur->right is null) | |
cur->right = node | |
cur = null | |
else | |
cur = cur->right | |
node->left = null | |
node->right = null | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment