正在加载图片...
else hl=high(t->child h2=high(t->nextsibling ) return(max(h1+l,h2)) 9对以孩子链表表示的树编写计算树的深度的算法。 算法略 10.对以双亲链表表示的树编写计算树的深度的算法。 typedef struct< dataty pe data Int parent 3 Node Type int high(NodeTypetl, int n) nash=0 for(i=0;<n;i++) if(t[]- parent==-1) h=1 else h=1; while(t[s]. parent!=-1) S- pa h++ if(h>math)145 else { h1=high(t->child ) ; h2=high(t->nextsibling ); return(max(h1+1,h2)); } } ⒐对以孩子链表表示的树编写计算树的深度的算法。 算法略 ⒑对以双亲链表表示的树编写计算树的深度的算法。 typedef struct{ datatype data; int parent ; }NodeType; int high(NodeType t[ ], int n) { maxh=0; for (i=0 ;i<n ;i++) { if (t[i].parent= = -1) h=1; else { s=i; h=1; while (t[s].parent != -1 ) { s=t[s].parent; h++; } } if (h>maxh)
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有