二叉树的遍历及应用.pptVIP

  • 35
  • 0
  • 约3.6千字
  • 约 25页
  • 2016-11-29 发布于江苏
  • 举报
练习:请画出通过先序遍历CreateBTree_Pre按下列次序输入字符时ABC##DE#G##F###创建的二叉树。 A B C D E G F 统计二叉树中结点总数 左子树结点数 + 右子树结点数 + 1(根结点) int BTreeCount(BTNode *root) { if(root==NULL) return 0; //空树的结点数为0 else return BiTreeCount( root-left ) + BiTreeCount( root-right ) +1; } 计算二叉树深度 左、右子树中深度较大的子树深度+1 int BTreeDepth(BTNode *root) { if(root==NULL) return 0; else{ int depl=BTreeDepth( root-left ); int depr=BTreeDepth( root-right ); if(depldepr) return depl+1; else return depr+1; } } 查找二叉树中值为item的结点 BTNode *FindBTree(BTNode* root, DataType item) {

文档评论(0)

1亿VIP精品文档

相关文档