码迷,mamicode.com
首页 >  
搜索关键字:symmetric tree    ( 18259个结果
LeetCode "Symmetric Tree"
Recursive.class Solution { public: bool isSymmetric(TreeNode *pl, TreeNode *pr) { if (!pl && !pr) return true; if ((pl && !pr)...
分类:其他好文   时间:2014-07-22 00:36:36    阅读次数:197
STL 源码剖析 算法 stl_heap.h
heap ------------------------------------------------------------------------- binary heap 是一种完全二叉树。 隐式表示法:以 array 表述 tree。 小技巧:将 array 的 #0 元素保留,则第 i 个元素的左右子节点分别是 2i 和 2i + 1, 父节点是i/2 --> STL 里没有采用这种小技巧 将 array 无法动态改变大小,所以用 vector 替代 array 这个文件里提供了各种堆操作的...
分类:其他好文   时间:2014-07-22 00:32:34    阅读次数:256
hoj Counting the algorithms
贪心加树状数组 给出的数据可能出现两种情况,包含与不包含,但我们从右向左删就能避免这个问题; #include #include #include using namespace std; const int maxn=200010; int f[maxn],l[maxn],a[maxn]; long long tree[maxn]; int n; inline int lowbit(int ...
分类:其他好文   时间:2014-07-22 00:27:36    阅读次数:210
平衡二叉树
平衡二叉树(Balanced binary tree)是由阿德尔森-维尔斯和兰迪斯(Adelson-Velskii and Landis)于1962年首先提出的,所以又称为AVL树。 定义:平衡二叉树或为空树,或为如下性质的二叉排序树:   (1)左右子树深度之差的绝对值不超过1;   (2)左右子树仍然为平衡二叉树.       平衡因子BF=左子树深度-右子树深度....
分类:其他好文   时间:2014-07-22 00:08:33    阅读次数:257
hdu 4601 Letter Tree 2013多校1-2
不容易啊。。一个小错误让我wa死了,找了一个晚上,怎么都找不到 最后是对拍代码找到的错误,发现当步数比较小的时候答案就是对的,比较大的时候就不对了 想到一定是什么地方越界了。。。 power[i] = (i64)(power[i - 1] * 26) % mod; 就是这行。。。 改成  power[i] = ((i64)power[i - 1] * 26) % mod;  就过了。。...
分类:其他好文   时间:2014-07-21 23:29:20    阅读次数:369
编程算法 - 二叉搜索树(binary search tree) 集合(set)和映射(map) 代码(C)
二叉搜索树(binary search tree) 集合(set)和映射(map) 代码(C++)本文地址: http://blog.csdn.net/caroline_wendy二叉搜索树(binary search tree)作为常用而高效的数据结构, 标准库中包含实现, 在标准库的集合(set)和映射(map), 均使用.具体操作代码如下.代码:/* * main.cpp * * C...
分类:其他好文   时间:2014-07-21 15:48:15    阅读次数:190
编程算法 - 二叉搜索树(binary search tree) 代码(C)
二叉搜索树(binary search tree) 代码(C)本文地址: http://blog.csdn.net/caroline_wendy二叉搜索树(binary search tree)可以高效的进行插入, 查询, 删除某个元素, 时间复杂度O(logn).简单的实现方法如下.代码:/* * main.cpp * * Created on: 2014.7.20 * Au...
分类:其他好文   时间:2014-07-21 15:15:16    阅读次数:273
hdu 1166线段树
线段树的一般模板,1.结构体数组tree来存储 2.线段树的构建函数buildTree 3.改变元素值函数update 4.查询区间内总和的函数query全部使用递归来实现 ######################################################################include #include #include #include us...
分类:其他好文   时间:2014-07-21 11:44:15    阅读次数:183
STL_稀疏图,树_使用vector邻接表存储
本文出自:http://blog.csdn.net/svitter 分析:vector是STL模板中的容器。可以利用其性质来构建邻接表。 定义: #include #define MAXN 10000 //max n of a tree or graph //if is a tree, n / 2 is OK ; using namespace std; typedef ve...
分类:其他好文   时间:2014-07-21 11:27:55    阅读次数:228
LeetCode "Balanced Binary Tree"
Another recursion problem.class Solution {public: int getHeight(TreeNode *p) { if (!p) return 0; int hL = 1; if (p->left) h...
分类:其他好文   时间:2014-07-21 11:10:03    阅读次数:180
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!