struct node* searchParent(struct node* root, int x)
{
if((root->left_child != NULL && root->left_child->data == x) || (root->right_child != NULL && root->right_child->data == x))
{
return root;
}
else
{
if(root->left_child != NULL && x < root->data)
{
return searchParent(root->left_child, x);
}
else
if(root->right_child != NULL && x > root->data)
{
return searchParent(root->right_child, x);
}
}
}