码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
【leetcode】Convert Sorted Array to Binary Search Tree (easy)
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.有序数组变二叉平衡搜索树,不难,递归就行。每次先序建立根节点(取最中间的数),然后用子区间划分左右子树。一...
分类:其他好文   时间:2014-11-27 23:20:29    阅读次数:269
[ACM] sdut 2882 Full Binary Tree (满二叉树的公共祖先)
Full Binary Tree Time Limit: 2000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 In computer science, a binary tree is a tree data structure in which each node has at most two children...
分类:其他好文   时间:2014-11-27 20:34:56    阅读次数:192
leetcode Symmetric Tree
这里是给定一个数,判断是不是对称的,即根据根画一竖直线对折重合一样。For example, this binary tree is symmetric: 1 / \ 2 2 / \ / \3 4 4 3But the following is not: 1 / \ ...
分类:其他好文   时间:2014-11-27 20:27:23    阅读次数:208
【LeetCode】Binary Tree Maximum Path Sum
Binary Tree Maximum Path SumGiven a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the be...
分类:其他好文   时间:2014-11-27 20:22:01    阅读次数:181
LeetCode:Binary Tree Zigzag Level Order Traversal
本题也属于层次遍历的变形,不同之处在于其遍历的方法是交替进行的,形成一个ZigZag的曲线形式,如下:代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* rig...
分类:其他好文   时间:2014-11-27 18:09:13    阅读次数:132
LeetCode:Binary Tree Level Order Traversal II
本题和上题一样同属于层次遍历,不同的是本题从底层往上遍历,如下:代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode* left; 4 TreeNode* right; 5 TreeNode(...
分类:其他好文   时间:2014-11-27 18:07:56    阅读次数:171
LeetCode:Binary Tree Level Order Traversal
题目:Binay Tree Level Order TraversalGiven a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level...
分类:其他好文   时间:2014-11-27 17:56:43    阅读次数:110
LeetCode:Maximum Depth of Binary Tree
要求:求二叉树的深度(二叉树的深度为最远叶子节点到根节点的距离,即根节点到最远叶子节点的距离)Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest ...
分类:其他好文   时间:2014-11-27 17:55:50    阅读次数:145
LeetCode:Construct Binary Tree from Preorder and Inorder Traversal
要求:通过二叉树的前序和中序遍历序列构建一颗二叉树代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x):...
分类:其他好文   时间:2014-11-27 17:49:13    阅读次数:220
LeetCode:Construct Binary Tree from Inorder and Postorder Traversal
要求:根据中序和后序遍历序列构建一棵二叉树代码如下: 1 struct TreeNode { 2 int val; 3 TreeNode *left; 4 TreeNode *right; 5 TreeNode(int x): val...
分类:其他好文   时间:2014-11-27 17:45:31    阅读次数:123
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!