已知二叉树的存储结构类型定义如下:typedef struct node{int data;struct node *lchil

已知二叉树的存储结构类型定义如下:
typedef struct node{
int data;
struct node *lchild, *rchild;
}BinNode;
typedef BinNode *BinTree;
请编写一个算法,求给定非空二叉树的中序遍历序列的第一个元素和最后一个元素的data域的值。函数原型为:void FirstLast(BinTree bt,int*first,int*last);
【正确答案】:void FirstLast(BinTree bt,int *first,int *last)
{ BinTree p;
p=bt;
while(p-> lchild != NULL) p=p-> lchild;
*first=p-> key;
p=bt;
while(p-> rchild !=NULL) p=p-> rchild;
*last=p-> key;
}