typedef struct BiTNode
{
ElemType data;
struct BiTNode *lchild,*rchild;
}BiTNode,*BiTree;
BiTNode *parent(BiTree T,ElemType x)
{
BiTNode *ans;
if(T==NULL)
return NULL;
if(T->lchild==NULL&&T->rchild==NULL)
return NULL
else
{
if(T->lchild->data==x||T->rchild->data==x)
return T;
else
{
ans=parent(T->lchild,x);
if(ans)
return ans;
ans=parent(T->rchild,x);
if(ans)
return ans;
return NULL;
}
}
}