Binary Search Tree Insert
Ok so we are doing Binary Search Trees. I have to do an insert function to add new data into the tree. The code below calls a recursive function to do this. However we are required to do this non recursively.
I have absolutely no idea where to start for this. a little guidance would be greatly appreciated. Thank you :)
Code:
void Insert(string data)
{
if (root != NULL)
{
Insert(data, root);
}
else
{
root = new node;
root->data = data;
root->left = NULL;
root->right = NULL;
}
}