《数据结构与算法设计》树-习题幻灯片资料.pptVIP

  • 15
  • 0
  • 约9.15千字
  • 约 37页
  • 2018-11-12 发布于天津
  • 举报

《数据结构与算法设计》树-习题幻灯片资料.ppt

《数据结构与算法设计》树-习题幻灯片资料.ppt

a. int BiTreeDepth(BiTree T) { int ldepth, rdepth; if ( !T ) return -1; ldepth = BiTreeDepth ( T-lchild ) ; rdepth = BiTreeDepth ( T-rchild ) ; if ( ldepth = rdepth ) T-depth = ldepth+1; else T-depth = rdepth+1; return T-depth; } ? ? ? b. Status BiTreeBalance(BiTree T) { int ldepth, rdepth; if ( T==NULL ) return TRUE; if (T-lchild) ldepth = T-lchild-depth; else ldepth = -1; if (T-rchild) rdepth = T-rchild-depth; else rdepth = -1; lrdepth = ldepth – rdepth; if ( ( lrdepth == 0 || lrdepth == 1 || lrde

文档评论(0)

1亿VIP精品文档

相关文档