主观

二叉树的存储结构类型定义如下

typedef int DataType;

typedef struct node

{DataType data;//data是数据域

struct nodelchild, rchild;//分别指向左右孩子

)BinTNode;

typedef BinTNode *BinTree;

阅读下列算法,并回答问题。

int height(BinTree T)

{

int lhigh=0, rhigh=;

if(T==NULL) return 0;

else{

Ihigh=height(T->);

rhigh=height(T->rchild);

if(lhigh>rhigh) return Ihigh+1:

else return rhigh+;

}

}

void f31(BinTree T)

int leftHigh=0, rightHigh=;

BinTree temp;

if(T==NULL)return;

else{

if(height(T->Ichild)rchild))

temp=T->Ichild;

T->Ichild=T->rchild;

T->rchild=temp;

}

31(T->lchild);

f31(T->rchild);

return;

}

(1)设二叉树T如题图所示,画出执行f31(T)后得到的二叉树T1。

(2)给出函数f31()的功能。

参考答案
您可能感兴趣的试题
¥

订单号:

遇到问题请联系在线客服

订单号:

遇到问题请联系在线客服