数据结构第章树.ppt

树具有下面两个特点: (1)树的根结点没有前驱结点,除根结点之外的所有结点有且只有一个前驱结点。 (2)树中所有结点可以有零个或多个后继结点。 结点(node) 结点的度(degree) 分支(branch)结点 叶(leaf)结点 孩子(child)结点 双亲(parent)结点 兄弟(sibling)结点 祖先(ancestor)结点 子孙(descendant)结点 结点所处层次(level) 树的高度(depth) 树的度(degree) 中序遍历 void inorder(JD *bt) { if(bt!=NULL) { inorder(bt-lchild); printf(%d\t,bt-data); inorder(bt-rchild); } } 后序遍历 void postorder(JD *bt) { if(bt!=NULL) { postorder(bt-lchild); postorder(bt-rchild); printf(%d\t,bt-data); } } 中序的非递归算法: void inorder(JD *bt) { int i=0; JD *p,*s[M]; p=bt; do { while(p!=NULL) {s

文档评论(0)

1亿VIP精品文档

相关文档