shu

所属分类:数据结构
开发工具:Visual C++
文件大小:8KB
下载次数:12
上传日期:2007-07-09 13:48:32
上 传 者Demonic
说明:  1.[问题描述] 编写递归算法,计算二叉树中叶子结点的数目 [输入] 按照先序序列的顺序输入该结点的内容。其输入abd eh cf i g . [输出] 按中序序列输出,输出的结果为;dbheaficg并计算出二叉树中叶子结点的数目为4 [存储结构] 采用二叉表存储 [算法的基本思想] 采用递归方法建立和遍历二叉树。首先建立二叉树的根结点,然后建立其左右子树,直到空子树为止,中序遍历二叉树时,先遍厉左子树,后遍厉右子树,最后访问根结点。根据左右子树的最后一个结点计算出二叉树中叶子结点的数目。 程序如下: #include<stdio.h> #include<malloc.h> #include"stdlib.h"
(1. [Description of the issue] to prepare recursive algorithm, Binary calculation leaves the number of nodes [imported] in accordance with the first order input sequence in the order of the node contents. Input abd eh i g cf. [Output] by the order sequence output, the results of the output; dbheaficg calculated Binary leaf node to the number four [storage structure] Table 2 forks storage [ The basic idea algorithm] recursive method and traverse binary tree. First established binary tree root node, and then to build their son around the tree, the tree until the loopholes, which preorder binary tree, Li first times the left sub-tree, right after Li times-tree root node final visit. Under the sub-trees around the last one node calculated Binary leaf node number. The procedure is as follows :#)

文件列表:
shu.doc (30720, 2007-07-09)

近期下载者

相关文件


收藏者