主题:新手求助,二叉树类的定义和实现的程序填空
高手帮忙,刚接触,无头绪啊,谢谢啦
typedef struct BinNode{
int data;
struct BinNode* leftchild, * rightchild;
}BinNode, *BinTree;
void InitBinTree(BinTree &root) //初始化二叉树root
{
root=Null;
}
void DestroyBinTree(BinTree &root) //销毁二叉树root
{
if (root == NULL) return;
DestroyBinTree(root->leftchild);
DestroyBinTree (root->rightchild);
free(root);
}
int countNodes1(BinTree &root) //计算二叉树root中度为1的结点数
{
if ( ① ___________ if(root!=NULL) ___________________ ){
if(root-> leftchild!=NULL && root-> rightchild!=NULL)
___②___ return root _________________________________________________;
else if(root-> leftchild==NULL && __③__ _______________________________ ___)
__④_ ___________________________________________________________;
else if (root-> leftchild!=NULL && ⑤ _____________________________ )
__⑥_ ___________________________________________________________;
}
return 0;
}
typedef struct BinNode{
int data;
struct BinNode* leftchild, * rightchild;
}BinNode, *BinTree;
void InitBinTree(BinTree &root) //初始化二叉树root
{
root=Null;
}
void DestroyBinTree(BinTree &root) //销毁二叉树root
{
if (root == NULL) return;
DestroyBinTree(root->leftchild);
DestroyBinTree (root->rightchild);
free(root);
}
int countNodes1(BinTree &root) //计算二叉树root中度为1的结点数
{
if ( ① ___________ if(root!=NULL) ___________________ ){
if(root-> leftchild!=NULL && root-> rightchild!=NULL)
___②___ return root _________________________________________________;
else if(root-> leftchild==NULL && __③__ _______________________________ ___)
__④_ ___________________________________________________________;
else if (root-> leftchild!=NULL && ⑤ _____________________________ )
__⑥_ ___________________________________________________________;
}
return 0;
}