1. 题目:
如题;
2. 代码:
typedef struct CSNode{
ElemType data;
struct CSNode *firstchild,*nextsibling;
}CSNode,*CSTree;
int Height(CSTree bt){
int hc,hs;
if(!bt)
return 0;
hc=Height(bt->firstchild); //第一女子树高
hs=Height(bt->nextsibling); //兄弟树高
if(hc+1>hs)
return hc+1;
return hs;
}
3. 知识点:
孩子兄弟表示法
本文介绍了一种特殊的数据结构表示法——孩子兄弟表示法,并通过一个具体的示例展示了如何利用该表示法来计算树的高度。文章还提供了一段实现此功能的C语言代码。
5409

被折叠的 条评论
为什么被折叠?



