Skip to content

Instantly share code, notes, and snippets.

@ButlerFuqua
Created April 12, 2021 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ButlerFuqua/e24559da781a1f6527c7499e1a09331b to your computer and use it in GitHub Desktop.
Save ButlerFuqua/e24559da781a1f6527c7499e1a09331b to your computer and use it in GitHub Desktop.
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