码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
leetcode Convert Sorted List to Binary Search Tree
把一个有序链表构成成平衡二叉树。和上一题有一点像。思路一:将有序链表存在一个数组里。然后根据每次访问中间节点当做根节点递归左右子树节点即可。代码如下:/** * Definition for singly-linked list. * struct ListNode { * int val;...
分类:其他好文   时间:2014-11-29 22:53:04    阅读次数:271
leetcode Convert Sorted Array to Binary Search Tree
利用更有序数组,构造平衡二叉树。思路,递归,每次中间节点为根节点,然后递归获得左右子树。/** * Definition for binary tree * struct TreeNode { * int val; * TreeNode *left; * TreeNode *...
分类:其他好文   时间:2014-11-29 22:52:43    阅读次数:239
Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 ...
分类:其他好文   时间:2014-11-29 21:37:03    阅读次数:330
【LeetCode】Convert Sorted Array to Binary Search Tree
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.这题思路参照Conve...
分类:其他好文   时间:2014-11-29 20:07:35    阅读次数:178
LeetCode:Flatten Binary Tree to Linked List
要求:Given a binary tree, flatten it to a linked list in-place.将二叉树转化为平坦序列的树。比如:结题思路:该题有个提示,转化后的树的序列正好是二叉树前序遍历所得到的序列,所以,该题第一个思路就是利用前序遍历的方式来做。第二个思路:我们可以利...
分类:其他好文   时间:2014-11-29 18:48:51    阅读次数:196
LeetCode:Minimum Depth of Binary Tree
要求:此题正好和Maximum Depth of Binary Tree一题是相反的,即寻找二叉树的最小的深度值:从根节点到最近的叶子节点的距离。结题思路:和找最大距离不同之处在于:找最小距离要注意(lleft);13 int r = minDepth(root->right);14 ...
分类:其他好文   时间:2014-11-29 18:47:40    阅读次数:182
[十大数据挖掘算法] AdaBoost
AdaBoost Binary ClassifyAdaBoost MultidimensionalWEKA源码分析
分类:编程语言   时间:2014-11-29 18:46:37    阅读次数:133
【LeetCode】Balanced Binary Tree
Balanced Binary TreeGiven a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tre...
分类:其他好文   时间:2014-11-29 17:33:54    阅读次数:169
Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing all ones and return its area.参考:http://xpentium.blog.163.com/b...
分类:其他好文   时间:2014-11-29 17:32:47    阅读次数:168
LeetCode:balanced binary tree
这道题也不是非常的难,弄楚平衡二叉树(AVL)的判断方法就行:1.判断左子树高度与右子树高度之差是否小于12.判断根节点左子树是否满足平衡二叉3.判断根节点右子树是否满足平衡二叉满足以上三个条件才是AVL树 1 /** 2 * Definition for binary tree 3 * str.....
分类:其他好文   时间:2014-11-29 17:31:39    阅读次数:199
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!