Last active
December 24, 2015 17:59
-
-
Save jotaki/6840066 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
struct node_s * add_node(struct node_s ** tree, struct node_s * leaf) | |
{ | |
if(*tree == NULL) | |
*tree = leaf; | |
else if((*tree)->key > leaf->key) { | |
leaf->right = *tree; | |
*tree = leaf; | |
} | |
else if((*tree)->key < leaf->key) { | |
leaf->left = *tree; | |
*tree = leaf; | |
} | |
else { // == | |
free(*tree); | |
*tree = leaf; | |
} | |
return leaf; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment