文件名称:2
- 所属分类:
- 数据结构常用算法
- 资源属性:
- [C/C++] [源码]
- 上传时间:
- 2012-11-26
- 文件大小:
- 1kb
- 下载次数:
- 0次
- 提 供 者:
- zhoup******
- 相关连接:
- 无
- 下载说明:
- 别用迅雷下载,失败请重下,重下不扣分!
介绍说明--下载内容均来自于网络,请自行研究使用
二叉排序树的创建与使用
(时间限制为:1000毫秒)
描述:
二叉排序树的定义是:或者是一棵空树,或者是具有下列性质的二叉树:(1)若它的左子树不空,则左子树上所有的结点值均小于它的根结点的值;(2)若它的右子树不空,则右子树上所有结点的值均大于或等于它的根结点的值;(3)它的左右子树也分别为二叉排序树。现要求根据输入的元素值,构造一棵二叉排序树,并输出其先序遍历、中序遍历和后序遍历结果。
输入:
输入第一行为测试用例个数n,接下来为n个测试用例,每个测试用例占两行,其中第一行为元素个数m,第二行为m个需要构造成二叉排序树的元素值。
输出:
每个测试用例用三行输出,其中第一行输出先序遍历结果,第二行输出中序遍历结果,第三行输出后序遍历结果。各元素之间用一个空格隔开。
样例输入:
1
5
8 4 2 6 4
样例输出:
8 4 2 6 4
2 4 4 6 8
2 4 6 4 8
-Binary Sort Tree creation and use of
(Time limit: 1000 ms)
Descr iption:
Binary sort tree is defined as: either an empty tree, or the nature of the binary tree with the following: (1) if its left subtree is not empty, then the left sub-tree of all nodes were less than the value of its root node (2) if it s the right subtree is not empty, then the right sub-tree of all nodes are greater than or equal to the value of its root node (3) around its sub- tree were binary sort tree. Are required elements of the input value, a binary sort tree structure, and the output of its first order traversal, inorder traversal and postorder traversal results.
Input:
Enter the number of the first acts of the test case n, then for the n test cases, accounting for two lines of each test case, where the first acts of the number of elements m, m a need to construct the second act into a binary sort tree of element values .
Output:
With three lines of output for each test case, wh
(时间限制为:1000毫秒)
描述:
二叉排序树的定义是:或者是一棵空树,或者是具有下列性质的二叉树:(1)若它的左子树不空,则左子树上所有的结点值均小于它的根结点的值;(2)若它的右子树不空,则右子树上所有结点的值均大于或等于它的根结点的值;(3)它的左右子树也分别为二叉排序树。现要求根据输入的元素值,构造一棵二叉排序树,并输出其先序遍历、中序遍历和后序遍历结果。
输入:
输入第一行为测试用例个数n,接下来为n个测试用例,每个测试用例占两行,其中第一行为元素个数m,第二行为m个需要构造成二叉排序树的元素值。
输出:
每个测试用例用三行输出,其中第一行输出先序遍历结果,第二行输出中序遍历结果,第三行输出后序遍历结果。各元素之间用一个空格隔开。
样例输入:
1
5
8 4 2 6 4
样例输出:
8 4 2 6 4
2 4 4 6 8
2 4 6 4 8
-Binary Sort Tree creation and use of
(Time limit: 1000 ms)
Descr iption:
Binary sort tree is defined as: either an empty tree, or the nature of the binary tree with the following: (1) if its left subtree is not empty, then the left sub-tree of all nodes were less than the value of its root node (2) if it s the right subtree is not empty, then the right sub-tree of all nodes are greater than or equal to the value of its root node (3) around its sub- tree were binary sort tree. Are required elements of the input value, a binary sort tree structure, and the output of its first order traversal, inorder traversal and postorder traversal results.
Input:
Enter the number of the first acts of the test case n, then for the n test cases, accounting for two lines of each test case, where the first acts of the number of elements m, m a need to construct the second act into a binary sort tree of element values .
Output:
With three lines of output for each test case, wh
相关搜索: 二叉排序树
(系统自动生成,下载前可以参看下载内容)
下载文件列表
二叉排序树的创建与使用.cpp