码迷,mamicode.com
首页 >  
搜索关键字:binary trees    ( 12390个结果)
hdu 5200 Trees [ 排序 离线 2指针 ]
传送门TreesAccepts: 156Submissions: 533Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 65536/65536 K (Java/Others)Problem DescriptionToday CodeFamer ...
分类:编程语言   时间:2015-04-04 22:27:36    阅读次数:265
【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 path from the root node down to the farthest le...
分类:其他好文   时间:2015-04-04 22:22:21    阅读次数:229
Lowest Common Ancestor of The Two Nodes in a Binary Tree
root指向一棵二叉树的头结点,p和q分别指向该二叉树中任意两个结点的指针,编写算法,找到p和q的最近公共祖先结点r。 为了不失一般性,设p在q的左边。同时,为了编写方便,将以p和q所指结点的值代替p和q本身。根据【后续遍历最后访问根节点,在递归算法中,根是压在栈底的】,很容易想到,采用后序遍历非递归算法:栈中存放二叉树结点的指针。当访问到某结点时,栈中所有的元素都是该结点的祖先。设一个辅助栈,当没...
分类:其他好文   时间:2015-04-04 21:18:20    阅读次数:150
leetcode_Validate Binary Search Tree
思路: 由于二叉排序树的中序遍历序列是有序的,所以考虑在遍历的过程中通过判断遍历序列是否有序从而来判断该排序树是否有效,但这又涉及到第一个元素的问题,所以可以设一个比Integer.MAX_INT还小的值作为参考值或者设一个flag来判断是否是第一个值,第一个值直接跳过即可。...
分类:其他好文   时间:2015-04-04 21:15:48    阅读次数:118
LeetCode - Binary Tree Level Order Traversal II
二叉树的层序遍历思路一:利用队列,将每一层节点放入队列,各层节点之间加入NULL隔开。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 ...
分类:其他好文   时间:2015-04-04 19:44:40    阅读次数:110
leetcode_num95_Unique BT II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example, Given n = 3, your program should return all 5 unique BST's shown below. 1 3 ...
分类:其他好文   时间:2015-04-04 18:28:21    阅读次数:116
Leetcode 199 Binary Tree Right Side View
1.题目要求Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For ...
分类:其他好文   时间:2015-04-04 16:36:31    阅读次数:105
[LeetCode] Binary Tree Right Side View 二叉树的右侧视图
Given a binary tree, imagine yourself standing on therightside of it, return the values of the nodes you can see ordered from top to bottom.For exampl...
分类:其他好文   时间:2015-04-04 16:35:06    阅读次数:102
LeetCode: Convert Sorted List to Binary Search Tree 解题报告
Convert Sorted List to Binary Search TreeGiven a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST....
分类:其他好文   时间:2015-04-04 15:01:48    阅读次数:117
学习笔记:LeetCode100:Same Tree
LeetCode100:Same TreeGiven two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are stru...
分类:其他好文   时间:2015-04-04 13:25:00    阅读次数:94
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!