Given inorder and postorder traversal of a tree, construct the binary tree. Note: You may assume that duplicates do not exist in the tree. 利用中序和后序遍历构造 ...
分类:
其他好文 时间:
2017-06-08 17:56:09
阅读次数:
235
题目描写叙述: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. ...
分类:
其他好文 时间:
2017-06-07 16:20:32
阅读次数:
187
Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Re ...
分类:
其他好文 时间:
2017-06-06 23:25:03
阅读次数:
224
该题的思路非常明白就是将中缀表达式转换为后缀表达式。然后通过后缀表达式来求值。 class Solution { public: int calculate(string s) { vector<string> postorder; stack<char> ccache; stack<int> ic ...
分类:
其他好文 时间:
2017-05-24 13:44:03
阅读次数:
190
public enum BinaryTreeTraversal { PreOrder, InOrder, PostOrder } public class BianaryTreeNode { public BianaryTreeNode Left { get; set; } public Biana ...
分类:
其他好文 时间:
2017-04-05 21:51:28
阅读次数:
139
一、描述: 二、思路: 二叉树的中序遍历和前序遍历或和后续遍历能唯一确定一节课二叉树,即2中还原方式都需要中序遍历才能完成; 设二叉树的前序遍历序列为{1, 2, 4, 5, 3, 6},中序遍历序列为{4,2,5,1, 3, 6}:(红色标记表示以还原节点!!!) (1)-前序遍历的第一个节点是二 ...
分类:
其他好文 时间:
2017-04-02 11:34:43
阅读次数:
164
思路一:递归版本 思路二:非递归版本,前序遍历中使用了一个额外的指针,这里使用times记录节点出栈的次数,更加方便直观 ...
分类:
其他好文 时间:
2017-04-02 11:04:29
阅读次数:
118
Given a binary tree, return the postorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, return [3,2,1]. Note: Recursive sol ...
分类:
其他好文 时间:
2017-03-23 13:48:46
阅读次数:
120
1. Recursive Straight Forward, left -> right -> root 2. Iterator This is a little bit hard to understand, here is good reference https://sites.google. ...
分类:
其他好文 时间:
2017-03-12 10:44:36
阅读次数:
222