Skip to content

Instantly share code, notes, and snippets.

@ferreiro
Created April 10, 2016 12:36
Show Gist options
  • Save ferreiro/e3e2d85da4e73ea34d24092e21c9cec3 to your computer and use it in GitHub Desktop.
Save ferreiro/e3e2d85da4e73ea34d24092e21c9cec3 to your computer and use it in GitHub Desktop.
node * insert(node * root, int value) {
if (!root){
node *newLeaf;
newLeaf->data = value;
newLeaf->left = NULL;
newLeaf->right = NULL;
root = newLeaf;
}
else {
int key = root->data;
if (value <= key) {
return insert(root->left, value);
} else {
return insert(root->right, value);
}
}
return root;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment