Thank you for the help and explanations! Things are a lot clearer now.
TreeSearch():
Code:
/* TreeSearch: search for target starting at node root.
* Pre: The tree to which root points has been created.
* Post: The function returns a pointer to a tree node that matches target
* or NULL if the target is not in the tree.
*/
TreeNode *TreeSearch(TreeNode *root, KeyType target)
{
if(root)
if(LT(&target, root->entry.key))
root = TreeSearch(root->left, target);
else if (GT(&target, root->entry.key))
root = TreeSearch(root->right, target);
return root;
}
Also I've been getting a warning from the complier for search in DoCommand() for the line in red:
warning: passing argument 2 of âTreeSearchâ makes integer from pointer without a cast