
二叉树
zhengde152
这个作者很懒,什么都没留下…
展开
-
二叉搜索树
二叉搜索树 判断两序列是否为同一二叉搜索树序列Input开始一个数n,(1<=n<=20) 表示有n个需要判断,n= 0 的时候输入结束。 接下去一行是一个序列,序列长度小于10,包含(0~9)的数字,没有重复数字,根据这个序列可以构造出一颗二叉搜索树。 接下去的n行有n个序列,每个序列格式跟第一个序列一样,请判断这两个序列是否能组成同一颗二叉搜索树。Outpu...原创 2018-08-26 21:03:34 · 178 阅读 · 0 评论 -
Trees on the level
Trees on the level Trees are fundamental in many branches of computer science. Current state-of-the art parallel computers such as Thinking Machines' CM-5 are based on fat trees. Quad- and octal-t...原创 2018-08-26 21:07:16 · 143 阅读 · 0 评论 -
Not so Mobile
Not so Mobile 题的链接:https://vjudge.net/contest/248639#problem/B题意:给你一个树形的天平,如图所示,根据力矩相等原则判断是否相等。(在紫书上有详细的解答和代码)注意:输入的时候采用(先序)输入,如果WL为0时,该天平有左子天平,接下来描述这个左子天平,如果WR为0时,该天平有有右子天平,接下来描述这个右子...原创 2018-08-26 21:15:52 · 155 阅读 · 0 评论 -
Tree
Tree题链接:https://vjudge.net/contest/248639#problem/C题解:给一棵点带权(权值各不相同,都是小于10000的正整数)的二叉树的中序和后序遍历,找一个叶子使得它到根的路径上的权和最小。如果有多解,该叶子本身的权应尽量小。输入中每两行表示一棵树,其中第一行为中序遍历,第二行为后序遍历。紫书上有详细解释和代码代码:#include &...原创 2018-08-26 21:24:17 · 111 阅读 · 0 评论 -
The Falling Leaves
The Falling Leaves题链接;https://vjudge.net/contest/248639#problem/D 题解:给你一棵二叉树(先序遍历),输入-1表示无此节点。一个节点的左节点在其左边一个单位,右节点在其右边一个单位,判断这棵树竖直方向上之和最大为多少(例如一个节点跟它左节点的右节点在同一竖直方向上,跟它右节点的左节点在同一个竖直方向上) 。将树存在一个水平一维...原创 2018-08-26 21:28:28 · 300 阅读 · 0 评论 -
S-Trees
S-Trees题链接:https://vjudge.net/contest/249113#problem/B题解:1走右孩子,0走左孩子,给出三层节点的顺序,给出叶子节点的值,给出路径,问最后的到达叶子节点的值 代码:#include<stdio.h>#include<string.h>#include<math.h>char a[101...原创 2018-08-26 21:38:26 · 304 阅读 · 0 评论 -
The order of a Tree
The order of a TreeAs we know,the shape of a binary search tree is greatly related to the order of keys we insert. To be precisely: 1. insert a key k to a empty tree, then the tree become a tree w...原创 2018-08-23 13:10:05 · 181 阅读 · 0 评论 -
Tree Recovery
Tree RecoveryLittle Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital letters in the nodes. This is an example of on...原创 2018-08-21 14:25:21 · 819 阅读 · 0 评论