1 class Solution { 2 public TreeNode buildTree(int[] inorder, int[] postorder) { 3 return helper(postorder.length-1, 0, inorder.length - 1, inorder, p... ...
分类:
其他好文 时间:
2018-09-20 11:28:23
阅读次数:
106
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to out ...
分类:
其他好文 时间:
2018-09-15 20:55:10
阅读次数:
151
找中序遍历的后一个节点,那就中序遍历到当前节点后再往后一个,可以用递归,也可以非递归,完全没有用到BST的性质。 也可以充分利用BST的性质,如果p比当前节点小,说明在左子树,res=root;否则去右子树搜索。 ...
分类:
其他好文 时间:
2018-09-01 12:39:00
阅读次数:
144
leetcode上刷到一题中序遍历一颗二叉树的题,两种方法,使用递归或者栈 原题及解答:https://leetcode.com/problems/binary-tree-inorder-traversal/discuss/164579/recursion-and-stack-solve-the-p ...
分类:
Web程序 时间:
2018-08-30 02:07:15
阅读次数:
220
Construct Binary Tree from Preorder and Inorder Traversal /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode lef... ...
分类:
其他好文 时间:
2018-08-28 21:13:50
阅读次数:
176
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
分类:
其他好文 时间:
2018-08-24 21:46:35
阅读次数:
197
[抄题]: Given inorder and postorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For ex ...
分类:
编程语言 时间:
2018-08-24 00:39:40
阅读次数:
136
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
分类:
其他好文 时间:
2018-08-19 15:46:04
阅读次数:
139
Given preorder and inorder traversal of a tree, construct the binary tree. Note:You may assume that duplicates do not exist in the tree. For example, ...
分类:
其他好文 时间:
2018-08-19 13:57:40
阅读次数:
107
bst to dll NOT TESTED YET public Node head = null; public Node prev = null; public void inOrder(Node root){ if(root == null){ return; } inOrder(root.l... ...
分类:
其他好文 时间:
2018-08-17 00:42:51
阅读次数:
158