typedef struct BiTNOde{
ElemType data; //数据域
struct BiTNode *lchild,*rchild; //左、右孩子指针
}BiTNode,*BiTree;
//先序遍历(PreOrder)
void PreOrder(BiTree T){
if(T!=NULL){
visit(T);
PreOrder(T->lchil...
分类:
其他好文 时间:
2015-03-21 18:43:22
阅读次数:
198
具体思路和中序遍历是一致的,只是访问结点的值的时机不同罢了,具体思路参见:http://blog.csdn.net/mnmlist/article/details/44312315...
分类:
其他好文 时间:
2015-03-20 16:33:15
阅读次数:
121
递归遍历算法把要调用函数自身的部分当成是已经完成的,再去按正常的思想去思考。先根遍历算法PreOrder(t)//t为二叉树的根节点PreOrder1.[递归出口] IF t==NULL THEN RETURN。PreOrder2.[访问根] PRINT(Data(t)).Pre...
分类:
编程语言 时间:
2015-03-19 21:46:54
阅读次数:
214
Only different with preorder and postorder is that the root start from the beginning for preorder. 1 /** 2 * Definition for binary tree 3 * struct T.....
分类:
其他好文 时间:
2015-03-19 06:20:26
阅读次数:
122
Still 3 methods:Same with inorder, but post order is a little different. We need to treat it as reverse result of preorder.So we go to right branch fi...
分类:
其他好文 时间:
2015-03-18 08:57:58
阅读次数:
132
/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *right; * TreeNode(int x) : val(x), left(...
分类:
其他好文 时间:
2015-03-16 23:05:38
阅读次数:
181
Given a binary tree, return theinordertraversal of its nodes' values.和preorder是一样的,把左子节点一直压入到栈中,直到没有左子节点为止,然后出栈访问,存储右子节点。 1 vector inorderTraversal(Tr...
分类:
其他好文 时间:
2015-03-15 00:42:02
阅读次数:
111
Given a binary tree, return thepreordertraversal of its nodes' values.简单题,递归和迭代都可以解。 1 class Solution { 2 public: 3 vector preorderTraversal(TreeN...
分类:
其他好文 时间:
2015-03-15 00:41:43
阅读次数:
104
Construct Binary Tree from Preorder and Inorder Traversal问题:Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may ass...
分类:
其他好文 时间:
2015-03-14 13:43:43
阅读次数:
121
Given a binary tree, return the preorder traversal of its nodes' values.For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3return [1,2,3]...
分类:
其他好文 时间:
2015-03-12 12:48:57
阅读次数:
95