码迷,mamicode.com
首页 >  
搜索关键字:binary    ( 11734个结果)
[LeetCode] Binary Tree Longest Consecutive Sequence 二叉树最长连续序列
Given a binary tree, find the length of the longest consecutive sequence path. The path refers to any sequence of nodes from some starting node to any
分类:其他好文   时间:2016-03-08 07:05:03    阅读次数:169
Java [Leetcode 144]Binary Tree Preorder Traversal
题目描述: Given a binary tree, return the preorder traversal of its nodes' values. For example:Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. 解题思路
分类:编程语言   时间:2016-03-08 00:31:58    阅读次数:168
二分查找
1、二分查找(Binary Search) 二分查找又称折半查找,它是一种效率较高的查找方法。 二分查找要求:线性表是有序表,即表中结点按关键字有序,并且要用向量作为表的存储结构。不妨设有序表是递增有序的。2、二分查找的基本思想 二分查找的基本思想是:(设R[low..high]是当前的查找区间) 
分类:其他好文   时间:2016-03-07 22:17:18    阅读次数:222
Leetcoede 112 Path Sum 二叉树
二叉树的从叶子到根的和是否存在 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *right; 7 * TreeNode(int x) :
分类:其他好文   时间:2016-03-07 20:51:26    阅读次数:162
[LeetCode]题解(python):103-Binary Tree Zigzag Level Order Traversal
题目来源: https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/ 题意分析: Z字宽度遍历树。 题目思路: 这题可以用比较取巧的方法。首先获得宽度遍历的结果,然后将第二层的翻转就可以了。 代码(python):
分类:编程语言   时间:2016-03-07 19:18:05    阅读次数:217
[LeetCode]题解(python):101-Symmetric Tree
题目来源: https://leetcode.com/problems/symmetric-tree/ 题意分析: 判断一棵树是不是镜像树。 题目思路: 判断左子树的左右子树是不是和右子树的右左子树相同。 代码(python): # Definition for a binary tree node
分类:编程语言   时间:2016-03-07 19:14:27    阅读次数:175
[LeetCode]题解(python):102- Binary Tree Level Order Traversal
题目来源: https://leetcode.com/problems/binary-tree-level-order-traversal/ 题意分析: 宽度优先搜索一颗二叉树,其中同一层的放到同一个list里面。比如: 3 / \ 9 20 / \ 15 7返回 [ [3], [9,20], [1
分类:编程语言   时间:2016-03-07 18:45:17    阅读次数:188
[LeetCode]题解(python):099-Recover Binary Search Tree
题目来源: https://leetcode.com/problems/recover-binary-search-tree/ 题意分析: 二叉搜索树中有两个点错了位置,恢复这棵树。 题目思路: 如果是没有空间复杂度限制还是比较简单。首先将树的值取出来,然后排序,将相应的位置判断是否正确。如果要特定
分类:编程语言   时间:2016-03-07 18:38:59    阅读次数:145
Leet Code OJ 235. Lowest Common Ancestor of a Binary Search Tree [Difficulty: Easy]
题目: Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defined betwee...
分类:其他好文   时间:2016-03-07 15:06:42    阅读次数:148
lintcode-easy-Subtree
You have two every large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of
分类:其他好文   时间:2016-03-07 09:04:13    阅读次数:139
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!