typedef struct CSTNode{
int data;
struct CSTNode *firstchild,*nextsibling;
}CSTNode,*CSTree;
int height(CSTree T){
if(!T)return 0;
int hc=height(T->firstchild);
int hs=height(T->nextsibling);
if(hc+1>hs)
return hc+1;
else
return hs;
}
int leaves(CSTree T){
if(!T)return 0;
if(T->firstchild==NULL)return 1+leaves(T->nextsibling);
return leaves(T->firstchild)+leaves(T->nextsibling);
}
void degree(CSTree T,int &d){
if(!T)return;
if(T->firstchild!=NULL){
CSTree p=T->firstchild;
int i=1;
while(p->nextsibling!=NULL){
p=p->nextsibling;
i++;
}
if(i>d)d=i;
}
degree(T->firstchild,d);
degree(T->nextsibling,d);
}