Before I begin writing this program that deals with the insertion and deletion of Binary search nodes, I was pondering on which parameters I need to pass for the different functions. For example, it has been brought to my attention that I need to call a search function before I can execute an add node function, so the compiler knows where to insert the particular node correctly. However, I'm not sure which parameters I need to pass through a given search and add function. here is my struct
struct numStruct
{
int info;
numStruct *lLink;
numStruct *rLink;
};
numStruct *root = NULL;
If I want to build a search function what parameters would I need to pass?
Here is my search function code so far...
bool searchTree(numStruct, int searchItem)
{
numStruct *current;
bool found = false;
if (root == NULL)
cout << "Cannot search an empty tree. " << endl;
else
{
current = root;
while (current !=NULL && !found)
{
if (current -> info == searchItem)
found = true;
else if (current -> info > searchItem)
current = current -> lLink;
else
current = current -> rLink;
}
}
return found;
}