105. Construct Binary Tree from Preorder and Inorder Traversal 题目链接:https://leetcode.com/problems/construct-binary-tree-from-preorder-and-inorder-trav ...
分类:
其他好文 时间:
2017-04-22 09:36:21
阅读次数:
231
题目 Given a binary tree, return the inorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,3,2]. Note: R ...
分类:
其他好文 时间:
2017-04-21 18:51:33
阅读次数:
154
这里使用递归的算法,特别需要递归中边界的判断 ...
分类:
其他好文 时间:
2017-04-16 12:27:37
阅读次数:
138
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. ...
分类:
其他好文 时间:
2017-04-10 15:16:28
阅读次数:
146
public enum BinaryTreeTraversal { PreOrder, InOrder, PostOrder } public class BianaryTreeNode { public BianaryTreeNode Left { get; set; } public Biana ...
分类:
其他好文 时间:
2017-04-05 21:51:28
阅读次数:
139
Given a binary tree, return the inorder traversal of its nodes' values.For example:Given binary tree [1,null,2,3], 1 \ 2 / 3return [1,3,2].Note: Recur ...
分类:
其他好文 时间:
2017-04-04 19:08:20
阅读次数:
117
一、描述: 二、思路: 二叉树的中序遍历和前序遍历或和后续遍历能唯一确定一节课二叉树,即2中还原方式都需要中序遍历才能完成; 设二叉树的前序遍历序列为{1, 2, 4, 5, 3, 6},中序遍历序列为{4,2,5,1, 3, 6}:(红色标记表示以还原节点!!!) (1)-前序遍历的第一个节点是二 ...
分类:
其他好文 时间:
2017-04-02 11:34:43
阅读次数:
164
思路一:递归版本 思路二:非递归版本,一般二叉树的中序遍历需要记录节点出栈的次数,在中序遍历中,当节点第二次出栈时才输出对应值,这里巧妙的使用一个额外的指针实现了这个功能 以上两种方法的时间和空间复杂度都是O(n); 思路三:使用Morris方法中序遍历,空间复杂度是O(1) ...
分类:
其他好文 时间:
2017-04-01 21:00:29
阅读次数:
170
Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note: If the given node has no in-order successor in ...
分类:
其他好文 时间:
2017-03-24 11:53:30
阅读次数:
141