文件名称:shu2
介绍说明--下载内容来自于网络,使用问题请自行百度
2.[问题描述]
编写递归算法,在二叉树中求位于先序序列中第K个位置的结点
[输入]
按照先序序列的顺序输入该结点的内容。其输入abd eh cf i g 。输入要求的位置
[输出]
若二叉树不空,按先序序列输出,求出所求位置的结点
[存储结构]
采用二叉表存储
[算法的基本思想]
采用递归方法建立和遍历二叉树。首先建立二叉树的根结点,然后建立其左右子树,直到空子树为止,先序遍历二叉树时,先遍厉左子树,后遍厉右子树,最后访问根结点并计算出二叉树中叶子结点的数目和第K个位置的结点
#include<stdio.h>
#include<malloc.h>
struct node{
char info
struct node*llink,*rlink
}
typedef struct node NODE
-2. [Descr iption of the issue] to prepare recursive algorithm, Binary for the first sequence sequence in the first position of the K-node [imported] in accordance with the first order input sequence in the order of the nodes content. Input abd eh i g cf. Import requirements of the position [output] if the binary tree is not empty, the first sequence by sequence output obtained by seeking the location of nodes [storage structure] Table 2 forks storage [algorithm for the basic idea] recursive method and Traversing binary tree. First established binary tree root node, and then to build their son around the tree, the tree until the loopholes, preorder binary tree, Li first times the left sub-tree, after repeatedly Li-right tree Finally visit root node and calculated Binary leaf nodes and the nu
编写递归算法,在二叉树中求位于先序序列中第K个位置的结点
[输入]
按照先序序列的顺序输入该结点的内容。其输入abd eh cf i g 。输入要求的位置
[输出]
若二叉树不空,按先序序列输出,求出所求位置的结点
[存储结构]
采用二叉表存储
[算法的基本思想]
采用递归方法建立和遍历二叉树。首先建立二叉树的根结点,然后建立其左右子树,直到空子树为止,先序遍历二叉树时,先遍厉左子树,后遍厉右子树,最后访问根结点并计算出二叉树中叶子结点的数目和第K个位置的结点
#include<stdio.h>
#include<malloc.h>
struct node{
char info
struct node*llink,*rlink
}
typedef struct node NODE
-2. [Descr iption of the issue] to prepare recursive algorithm, Binary for the first sequence sequence in the first position of the K-node [imported] in accordance with the first order input sequence in the order of the nodes content. Input abd eh i g cf. Import requirements of the position [output] if the binary tree is not empty, the first sequence by sequence output obtained by seeking the location of nodes [storage structure] Table 2 forks storage [algorithm for the basic idea] recursive method and Traversing binary tree. First established binary tree root node, and then to build their son around the tree, the tree until the loopholes, preorder binary tree, Li first times the left sub-tree, after repeatedly Li-right tree Finally visit root node and calculated Binary leaf nodes and the nu
(系统自动生成,下载前可以参看下载内容)
下载文件列表
shu2.doc
本网站为编程资源及源代码搜集、介绍的搜索网站,版权归原作者所有! 粤ICP备11031372号
1999-2046 搜珍网 All Rights Reserved.