
318 Data Structures Using C
struct binNode * findSucc(struct binNode *ptr)
{ struct binNode *succPtr;
getch();
succPtr = ptr->rightChild;
while (succPtr->leftChild != NULL)
succPtr = succPtr->leftChild ;
return succPtr;
}
struct binNode *searchBST (struct binNode *binTree, int val, int *flag)
{
if (binTree == NULL)
{*flag = 0;
return binTree;
}
else
{
if (binTree->val ==val)
{
*flag = 1;
return binTree;
}
else
{ if (val < binTree->val)
return searchBST(binTree->leftChild, val, flag);
else
return searchBST(binTree->rightChild, val, flag);
}
}
}
struct binNode *findParent (struct binNode *binTree, struct binNode *ptr)
{ struct binNode *pt;