题目6.61 试编写算法,求一棵以孩子-兄弟链表表示的树的度。
//树的孩子-兄弟链表表示
typedef struct CSNode
{
ElemType data;
struct CSNode *firstchild, *nextsibling;
}CSNode, *CSTree;
void Degree(CSTree T, int &d)
{
if(T != NULL)
{
if(T->firstchild != null)
{
p = T->firstchild;
n = 1;
while(p->nextsibling != NULL)
{
p = p->nextsibling;
n++;
}
if(n > d)
d = n;
}
Degree(T->firstchild, d);
Degree(T->nextsibling, d);
}
}