### Call to Tree Insertion Function

Hey

I've been looking at some example code for a recursive function that inserts an element into a binary search tree. It's a relatively simple function that takes two arguments: the tree to be inserted into and the value to be inserted, the prototype looks like this: ` node* insert(node* p_tree, int value)`. Don't get me wrong, I understand what the function does I'm just not sure what would be sent to the function from main as 'p_tree' eg. ` insert(Something, 10)`I'm assuming that you could write ` insert(NULL, 10)` on the first call but I'm completely clueless as to what you would do in any subsequent calls. Anyway, any help would be much appreciated and code showing a call from main would be great.

Cheers.

Last edited on

 ``12345678910111213141516171819202122232425262728293031323334`` `````` node* insert(node* p_tree, int value) { struct node* parent = (struct node*)malloc(sizeof(struct node)); p_tree->value = value; p_tree->left = NULL; p_tree->right = NULL; parent = NULL; if(IsEmptyTree()==1) root = p_tree; else { struct node* curr =(struct node*)malloc(sizeof(struct node)); curr = root; while(curr) { parent = curr; if( p_tree->value == curr->value ) curr = curr->right; else curr = curr->left; } if( p_tree->value < p_tree->value) parent->left = p_tree; else parent->right = p_tree; } return root; }``````