[Definitions]
Here is the recursive definition of a binary tree:
A binary tree is either the empty set or a triple T = (x,L,R), where x is a node and L and R are disjoint binary trees, neither of wh...
分类:
其他好文 时间:
2014-08-18 01:34:43
阅读次数:
216
二叉树的创建。这里采用最简单的情况,创建完全二叉树,用数组来保存: 1 struct TreeNode 2 { 3 int val; 4 TreeNode *left, *right; 5 TreeNode(int x): val(x), left(NULL), right(...
分类:
其他好文 时间:
2014-08-18 01:30:03
阅读次数:
332
Given n, how many structurally unique BST's (binary search trees) that store values 1...n?For example,Given n = 3, there are a total of 5 unique BST's...
分类:
其他好文 时间:
2014-08-18 00:03:13
阅读次数:
189
【Description】
At ree is a nonlinear data structure that models a hierarchical organization. The characteristic eatures are that each element may have several successors (called its “children”) and ev...
分类:
其他好文 时间:
2014-08-17 22:47:03
阅读次数:
275
class Solution {public: string convert(string s, int nRows) { int len = s.length(); if (len cols; int si = 0; int ri =...
分类:
其他好文 时间:
2014-08-17 21:21:32
阅读次数:
218
Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only n...
分类:
其他好文 时间:
2014-08-17 21:11:02
阅读次数:
213
Two elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure.Note:A solution using O(n) space is ...
分类:
其他好文 时间:
2014-08-17 21:08:02
阅读次数:
339
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree is symmetric: 1 / \ ...
分类:
其他好文 时间:
2014-08-17 19:55:32
阅读次数:
215
$\bf命题:$设$f(x,y)$为线性空间$V$上的非退化双线性函数,则对任何$g \in {V^*}$,存在唯一的$\alpha \in V$,使得$g\left( \beta \right) = f\left( {\alpha ,\beta } \right),\forall \beta \i...
分类:
其他好文 时间:
2014-08-17 19:51:32
阅读次数:
233
Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical an...
分类:
其他好文 时间:
2014-08-17 19:49:42
阅读次数:
190