
二叉树
synapse7
这个作者很懒,什么都没留下…
展开
-
UVa 112 Tree Summing (scanf()去空格&递归&二叉树遍历)
112 - Tree Summing Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=48 Background LISP was one of the earliest high-le原创 2013-10-04 12:49:06 · 1472 阅读 · 0 评论 -
UVa 11234 Expressions (二叉树重建&由叶往根的层次遍历)
思路: 1. 怎么建树?——对于给出的序列, 从左到右遍历,遇到代表数字的小写则建立一个无儿子的树(只保存值),然后把结点指针入栈;遇到代表操作符的大写字母,则从栈中弹出两个结点,然后建立一个以大写字母为根,弹出的两个节点为左右儿子的树,再把这个新树的根结点指针压入栈。如此循环下去。 最后,在栈顶的那个指针就是最后建成的树的根结点。 2. 怎么遍历输出?——模拟queue进行bfs扫描整棵树,扫描完成后逆序输出即可。 完整代码:原创 2013-10-24 10:38:50 · 1404 阅读 · 0 评论 -
UVa 10562 Undraw the Trees (二叉树先序遍历)
10562 - Undraw the Trees Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=104&page=show_problem&problem=1503 Professor Homer has been rep原创 2013-10-24 16:11:35 · 1225 阅读 · 0 评论 -
UVa 839 Not so Mobile (DFS二叉树)
839 - Not so Mobile Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=104&page=show_problem&problem=780 Before being an ubiquous communica原创 2013-10-24 19:31:40 · 1015 阅读 · 0 评论 -
UVa 548 Tree (中序遍历&后序遍历&DFS)
548 - Tree Time limit: 3.000 seconds http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=104&page=show_problem&problem=489 You are to determine the value of the leaf原创 2013-10-28 15:08:10 · 957 阅读 · 0 评论 -
UVa 712/POJ 1105/ZOJ 1150 S-Trees(用数组模拟二叉树)
712 - S-Trees Time limit: 3.000 seconds A Strange Tree (S-tree) over the variable set is a binary tree representing a Boolean function . Each path of the S-tree begins at theroot node and consi原创 2013-08-02 23:36:52 · 1251 阅读 · 0 评论 -
UVa 536 Tree Recovery (二叉树前序中序生成后序)
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem&problem=477 /*0.009s*/ #include #include void solve(char *pre, char *in, int n, char *post) {原创 2014-03-04 14:44:39 · 1369 阅读 · 0 评论