Created
April 10, 2016 12:36
-
-
Save ferreiro/e3e2d85da4e73ea34d24092e21c9cec3 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
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