当前位置:首页 > 数据结构(02331) > 正文内容

二叉树的二叉链表类型定义如下:
typedef struct node{
int data;
struct node *lchild,*rchild;
}BinNode;
typedef BinNode *BinTree;
编写函数f34(BinTree Bt),返回二叉树Bt中数据元素的最大值。
函数的原型为:int f34(BinTree Bt)。

高老师2年前 (2024-03-26)数据结构(02331)14

二叉树的二叉链表类型定义如下:
typedef struct node{
int data;
struct node *lchild,*rchild;
}BinNode;
typedef BinNode *BinTree;
编写函数f34(BinTree Bt),返回二叉树Bt中数据元素的最大值。
函数的原型为:int f34(BinTree Bt)。

#define Min -65525
int f34(BinTree BT)
{
int lvalue,rvalue,maxvalue;
if(BT==NULL)return Min;
if(BT!=NULL)
{
lvalue=f34(BT->lchild);
rvalue=f34(BT->rchild);
maxvalue=(lvalue>rvalue)?lvalue:rvalue;
maxvalue=(maxvalue>BT->data)?maxvalue:BT->data;
return maxvalue;
}

扫描二维码免费使用微信小程序搜题/刷题/查看解析。

版权声明:本文由翰林刷题小程序授权发布,如需转载请注明出处。

本文链接:https://doc.20230611.cn/post/431412.html

分享给朋友: