tree
我真的不会Coding
任何时候努力都不晚,要保持自信
展开
-
leetcode106. Construct Binary Tree from Inorder and Postorder Traversal
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 example, giveninorder = [9,3,15,20,7]postorder = [9...原创 2018-07-29 12:48:13 · 88 阅读 · 0 评论 -
110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never diff...转载 2018-07-29 17:51:23 · 72 阅读 · 0 评论 -
leetcode89
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Example 1:Input: [1,3,null,null,2] 1 / 3 \ 2Output: [3,1,null,nul...原创 2018-07-27 23:23:46 · 155 阅读 · 0 评论 -
红黑树
原 http://www.cnblogs.com/skywang12345/p/3245399.html随笔分类(275)Android(7) Android NDK编程(9) Android 系统层(5) Android 应用层(46) Computer Culture(2) Java(111) Linux/Ubuntu(5) UML(5) Windows(1) ...转载 2018-08-01 20:33:15 · 112 阅读 · 0 评论 -
深入学习理解二叉搜索树(附详细讲解与实例分析)
原博客 https://blog.csdn.net/qq_21396469/article/details/78419609 写在前面 本文主要分为三个部分。 第一部分介绍了二叉搜索树的基本性质。 第二部分全面详细地讲述了二叉搜索树的各种基本操作。包括WALK/遍历、SEARCH/查找、MINIMUM/最小关键字、MAXIMUM/...转载 2018-08-02 15:02:46 · 331 阅读 · 0 评论 -
111. Minimum Depth of Binary Tree最短深度 递归 BFS DFS
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no childre...原创 2018-08-02 22:27:48 · 163 阅读 · 0 评论 -
leetcode112. Path Sum路径之和 递归
DescriptionHintsSubmissionsDiscussSolutionPick OneGiven a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given...原创 2018-08-03 09:24:56 · 128 阅读 · 0 评论 -
存储路径:递归或者是DFSleetcode113. Path Sum II路径之和II递归DFS
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.Note: A leaf is a node with no children.Example:Given the below binary tree and sum = 22,...原创 2018-08-03 15:20:29 · 163 阅读 · 0 评论 -
判断一棵二叉树是否是平衡二叉树
输入一棵二叉树,判断该二叉树是否是平衡二叉树。 首先,平衡二叉树的定义:/*平衡二叉搜索树(Balanced Binary Tree)具有以下性质:它是一棵空树或它的左右两个子树的高度差的绝对值不超过1,并且左右两个子树都是一棵平衡二叉树*/ 所以我想到的是递归的方法,判断左右的高度差。 第一种方法用来判断该二叉树是否为平衡二叉树struct TreeNo...原创 2018-08-16 10:26:54 · 283 阅读 · 0 评论