Question:Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: ...
分类:
其他好文 时间:
2015-07-14 17:08:38
阅读次数:
69
该题比较简单,递归交换每一个节点的左右子树即可。
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
if(root == NULL)
return NULL;
TreeNode* tmp = root -> left;
root -> le...
分类:
其他好文 时间:
2015-07-14 15:46:50
阅读次数:
89
堆排序虽然叫heap sort,但是和内存上的那个heap并没有实际关系。算法上,堆排序一般使用数组的形式来实现,即binary heap。我们可以将堆排序所使用的堆int[] heap视为一个完全二叉树,即,除非最后一层右侧有空结点,其他都为满结点。对于任意heap[i]有如下一些性质:1. i从...
分类:
编程语言 时间:
2015-07-14 15:31:31
阅读次数:
147
题目: 096 Unique Binary Search Trees这道题目就是catalan数, 因为递归关系 为 代码为class Solution: # @param {integer} n # @return {integer} def numTrees(self, n)...
分类:
其他好文 时间:
2015-07-14 15:19:13
阅读次数:
93
题目:Given a binary search tree, write a functionkthSmallestto find thekth smallest element in it.Note:You may assume k is always valid, 1 ≤ k ≤ BST's t...
分类:
其他好文 时间:
2015-07-14 15:13:55
阅读次数:
98
Question: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 ...
分类:
其他好文 时间:
2015-07-14 15:06:50
阅读次数:
84
Question:Given a binary tree, return thebottom-up level ordertraversal of its nodes' values. (ie, from left to right, level by level from leaf to root...
分类:
其他好文 时间:
2015-07-14 15:04:32
阅读次数:
98
houdini 是intel 研发的ARM binary translator解决Android x86 系统的兼容性问题可以安装各种安卓中文输入法,允许各种安卓游戏,号称可以兼容90%以上的安卓应用!关键词:Android x86中文输入法应用兼容性。在玩Android x86 系统的时候,很多童...
分类:
移动开发 时间:
2015-07-14 15:01:42
阅读次数:
153
Given a binary tree, return the postorder traversal of its nodes’ values.For example:
Given binary tree {1,#,2,3},
return [3,2,1].Note: Recursive solution is trivial, could you do it iteratively?二叉...
分类:
其他好文 时间:
2015-07-14 13:47:27
阅读次数:
181
1. 问题描述 给定一棵二叉搜索树(BST),查找两个节点的最短公共祖先节点。
2. 方法与思路 这是一个简化的LCA问题,由于是二叉搜索树,树的本身就有一定节点,左儿子节点的值小于父节点值,父节点值小于右儿子节点的值。这样我们可以递归查找就可以了,如果当前节点值大于给定两个节点的值就去它的左子树查找,如果当前节点的值小于给定两个节点的值,就去它的右子树查找,否则返回该节点。
/**...
分类:
其他好文 时间:
2015-07-14 13:36:43
阅读次数:
74