一道HULU的笔试题(How I wish yesterday once more)假设有棵树,长下面这个样子,它的前序遍历,中序遍历,后续遍历都很容易知道。PreOrder: GDAFEMHZInOrder: ADEFGHMZPostOrder: AEFDHZMG现在,假设仅仅知道前序和中...
分类:
其他好文 时间:
2015-08-17 21:32:22
阅读次数:
121
Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3].
分类:
其他好文 时间:
2015-08-16 15:02:27
阅读次数:
102
struct BinaryTreeNode
{
int m_nValue;
BinaryTreeNode* m_pLeft;
BinaryTreeNode* m_pRight;
};
//递归前序遍历
void PreOrder(BinaryTreeNode* pNode)
{
if(pNode!=NULL)
{
coutm_nValue<<endl;
PreOrder(pNod...
分类:
编程语言 时间:
2015-08-16 12:17:13
阅读次数:
136
一、前序 1 public List preOrder(Node root){ 2 List res = new LinkedList(); 3 Stack stack = new Stack(); 4 stack.push(root); 5 while(root!=...
分类:
其他好文 时间:
2015-08-15 01:28:01
阅读次数:
116
Given a binary tree, return the preorder traversal of its nodes' values.
For example:
Given binary tree {1,#,2,3},
1
2
/
3
return [1,2,3].
Note: Recursive soluti...
分类:
其他好文 时间:
2015-08-11 23:34:22
阅读次数:
131
Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.
Note:
You may assume that duplicates do not exist in the tre...
分类:
其他好文 时间:
2015-08-11 18:58:28
阅读次数:
145
#include typedef struct BinTree{ int data; struct BinTree *left; struct BinTree *right;}BinTree;void PreOrder(BinTree *root){ if(root == NULL) return....
分类:
其他好文 时间:
2015-08-11 18:37:20
阅读次数:
105
【106-Construct Binary Tree from Preorder and Inorder Traversal(通过前序和中序遍历构造二叉树)】【LeetCode-面试算法经典-Java实现】【所有题目目录索引】原题 Given preorder and inorder traversal of a tree, construct the binary tree.
Note:...
分类:
编程语言 时间:
2015-08-09 07:13:59
阅读次数:
234
题目:Given a binary tree, return thepreordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,2,3]....
分类:
其他好文 时间:
2015-08-07 10:56:38
阅读次数:
112
??
#include
#include
#include
#include
using namespace std;
typedef struct Node
{
Node * lchild,*rchild;
char value;
} Tree;
void ReBuild(char *PreOrder,char *InOrder,int TreeLen,Tree** r...
分类:
其他好文 时间:
2015-08-06 20:34:44
阅读次数:
127