二叉树的二叉链表类型定义如下:
typedef struct node{
int data;
struct node *lchild,*rchild;
}BinNode;
typedef BinNode *BinTree;
编写函数f34(BinTree Bt),返回二叉树Bt中数据元素的最大值。
函数的原型为:int f34(BinTree Bt)。
【正确答案】:#tdefine Min -65525
Int f34(BinTree BT)
{
int lvalue,rvalue,maxvalue;
if(BT==NULL)return Min;
if(BT!=NULL)
{lvalue=f34(BT-> 1child);
rvalue=f34(BT-> rchild);
maxvalue=(lvalue> rvalue)?lvalue:rvalue;
maxvalue=(maxvalue> BT-> data)?maxvalue:BT-> data;
}
return maxvalue;
}
二叉树的二叉链表类型定义如下:typedef struct node{int data;struct node *lchild,
- 2024-11-07 01:34:52
- 数据结构与算法(13003)