2013年6月28日
摘要: 题目描述已知一棵二叉树的前序遍历和中序遍历,求二叉树的后序遍历。输入输入数据有多组,第一行是一个整数t (t 2 #include 3 #include 4 struct tree 5 { 6 char data; 7 struct tree *lchild,*rchild; 8 }; 9 struct tree *creat(struct tree *root,int len,char *s1,char *s2 )10 {11 if(len==0)12 {13 14 return NULL;15 }16 ... 阅读全文
posted @ 2013-06-28 20:56 straw_berry 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 题目描述 已知一个按先序序列输入的字符序列,如abc,,de,g,,f,,,(其中逗号表示空节点)。请建立二叉树并按中序和后序方式遍历二叉树,最后求出叶子节点个数和二叉树深度。输入输入一个长度小于50个字符的字符串。输出输出共有4行:第1行输出中序遍历序列;第2行输出后序遍历序列;第3行输出叶子节点个数;第4行输出二叉树深度。示例输入abc,,de,g,,f,,,示例输出cbegdfacgefdba35 1 #include 2 #include 3 #include 4 struct tree 5 { 6 char data; 7 struct tree *... 阅读全文
posted @ 2013-06-28 20:53 straw_berry 阅读(523) 评论(0) 推荐(0) 编辑