ChinaUnix.net
相关文章推荐:

伪代码 二叉树 深度遍历

这是叉树创建并中序遍历的程序可是一直有错 #include #define struct_sizes 20 #define adds 10 typedef struct bitnode { int data; struct bitnode *lchild,*rchild; }bitnode,*bitree; typedef struct { bitree *base; bitree *top; int stacksize; }sqstack; int initstack(sqstack *S) { S->base=(bitree*)malloc(struct_sizes*sizeof(bitree)); printf("chuan jian cheng gong"); if(!S->base)return ...

by xiaolifeidaotom - C/C++ - 2008-10-21 22:00:58 阅读(991) 回复(4)

相关讨论

[code]def isnum(a): if type(a)==type(1): return True return False def first_root(a): print a[1],'-', if isnum(a[0]): print a[0],'-', else: first_root(a[0]) if isnum(a[2]): print a[2],'-', else: first_root(a[2]) def middle_root(a): if isnum(a[0]): print a[0],'-', else: middle_root(a[0]) print a[1],'-', ...

by niexining - Python - 2007-12-11 22:54:52 阅读(2781) 回复(0)

叉树的后序遍历 不过不能用递归 也不能用栈

by billzhou - C/C++ - 2007-11-01 08:30:29 阅读(1154) 回复(4)

费了两天时间写的,包括前中后序遍历的递归和非递归算法,还有层序遍历总共2*3 + 1 = 7中遍历叉树的算法,感觉其中后序遍历的非递归算法比较困难,想了很久最后的实现还是不够优雅,请大家指正~~ 总共三个文件,一个头文件,一个对应的cpp文件,还有一个用于测试的文件. BinaryTree.h: [code] /******************************************************************** created: 2006/07/04 filename: BinaryTree.h author: 李创 ...

by converse - C/C++ - 2006-07-08 14:53:28 阅读(6641) 回复(3)

已知一棵叉树的先序遍历序列和中序遍历序列分别存于两个一维数组中;试编写算法建立该叉树叉链表。 

by blublusky - C/C++ - 2003-06-11 18:36:48 阅读(2011) 回复(10)

要求是这样的 现在我申请了一块共享内存 然后我有一个结构 struct A { int a; char b[10]; }; 我现在想在共享内存中建一个叉树,把这样的结构当作结点插进去 不知道应该怎么操作啊 谢谢大家了

by musg2000 - C/C++ - 2005-12-29 17:43:31 阅读(783) 回复(6)

#include #include typedef char elemtype; typedef struct node { elemtype data; struct node *lchild; struct node *rchild; }BinTNode,*BinTree; void CreatBinTree (BinTree *t); void preorder (BinTree t); void main () { BinTree t; CreatBinTree(&t); printf ("Print Previous Order:\n"); preorder (t); } void Cre...

by ktzlj - C/C++ - 2007-03-14 15:49:15 阅读(1268) 回复(5)

google查了一把,都是用堆栈来实现遍历的,可否用链表来实现遍历呢?thinking....

by chenzhanyiczy - C/C++ - 2008-06-17 00:52:46 阅读(1414) 回复(6)

看了版主converse写的叉树的递归与非递归遍历 http://www.cppblog.com/converse/archive/2006/07/08/9577.html 其中, 版主写到: "感觉其中后序遍历的非递归算法比较困难,想了很久最后的实现还是不够优雅" 俺也写了一个玩玩, 功能一样, 但是思路不一样, 呵呵 [code] #include #include #include using namespace std; struct node { node* lchild; node* rchild; int key; node(int da...

by ypxing - C/C++ - 2007-11-16 15:37:10 阅读(1686) 回复(1)

.................f .............../ \ .............d....e ............/ \ ...........a...c .................\ ..................b 后序遍历线索树顺序是a b c d e f,a线索b,b线索c,c如何前进到d?

by 菜鸟飞呀飞 - C/C++ - 2005-01-19 10:49:06 阅读(3448) 回复(8)

以中序遍历为例: void ProOrder(BT root) { if(root==NULL) return; else{ printf("%d",root->;data); ProOrder(root->;left); ProOrder(root->;right); } } 用没有哪位大侠可以详细的讲解一下,这个是如何递归调用并打印的? 我看了好久,用点似懂非懂,脑袋瓜实在是大!

by 流川 - C/C++ - 2004-10-07 10:27:38 阅读(1700) 回复(15)