2011年10月9日

用二叉树表示表达式

摘要: 先看中缀表达式的二叉树表示: /* * 中缀表达式 构建 二叉树 * * 方法: 每次找到“最后计算”的运算符,作为当前树的根,然后递归处理 * 详见 刘汝佳《算法竞赛入门经典》 P198 * */#include <iostream>using namespace std;const int maxn = 1000;//每个节点的左右儿子编号int lch[maxn], rch[maxn];//节点的字符char op[maxn];//节点数int cnt = 0;//s的[x, y)作为范围int buildTree(char *s, int x, int y... 阅读全文

posted @ 2011-10-09 23:10 龙豆 阅读(9126) 评论(0) 推荐(1)

POI-step traversing a tree 树的隔三遍历(题目)

摘要: http://smalloj.com/problem.php?pid=19 Step Traversing a TreeTime Limit:1000msMemory Limit:64000KiBAccepted:0Submitted:0 POI II Stage 3 Problem 2Step Traversing a TreeA graph is a pair (V,E), where V is a finite set of elements called vertices of the graph, and E is a subset of the set of all unord.. 阅读全文

posted @ 2011-10-09 22:03 龙豆 阅读(619) 评论(0) 推荐(0)

导航