主题:关于二叉树遍历的思考题
shuangwen163
[专家分:730] 发布于 2007-11-27 16:43:00
如果知道三种遍历中的任两种的表达试
怎么画出它的图?
回复列表 (共17个回复)
沙发
zdwzzu2006 [专家分:260] 发布于 2007-11-27 23:08:00
呵呵,这让怎么说啊,就是根据 先序,中序,后序的特点,注意与它相邻的点,及一些明显的位置特点。[em9]
3 楼
justforfun626 [专家分:18460] 发布于 2007-11-27 23:20:00
If you know how to do it by your eyes, pencil, and paper, you should be able to write a program to do the same.
Good luck!
4 楼
shuangwen163 [专家分:730] 发布于 2007-11-27 23:59:00
You are right!
i have a little laziness.
5 楼
mengxianfeng [专家分:10] 发布于 2007-11-29 17:17:00
我觉得要想确定一个二叉树,要有前序和中序或者后序和中序
因为从前序的头(后序的尾)在中序的位置可以确定根和左右子,从而递归确定整棵二叉数
基本思想就是这样的,不过要是写成程序还是很难!!!
6 楼
shuangwen163 [专家分:730] 发布于 2007-11-30 11:34:00
恩 我也是这么认为的
写算法可能很难写出.
7 楼
justforfun626 [专家分:18460] 发布于 2007-11-30 11:47:00
[size=8][b]What???!!![/b][/size] [em18]
That means you guys need to have more practice, write more programs, solve more problems!!!!
8 楼
shuangwen163 [专家分:730] 发布于 2007-12-01 12:57:00
I have tried my best to write it ,but realy didn't know how to solve it with program.
9 楼
justforfun626 [专家分:18460] 发布于 2007-12-01 13:24:00
preorder Root Left_subtree Right_subtree
inorder Left_subtree Root Right_subtree
postorder Right_subtree Root Left_subtree
Solve 3 node tree problem by using program first
Then increase the size
Make sure you can solve the problem by eye/paper/pencil first, not a trivial one, but has at least 45 nodes or more.
I suspect you don't know how yet!
10 楼
justforfun626 [专家分:18460] 发布于 2007-12-01 14:25:00
[quote]
preorder Root Left_subtree Right_subtree
inorder Left_subtree Root Right_subtree
postorder Right_subtree Root Left_subtree
[/quote]
From the above 3 lines, you know you need to decide the Root first, then do the same on Left_subtree. then Right_subtree recursively.
Problem solved!
我来回复