码迷,mamicode.com
首页 >  
搜索关键字:kmp 算法    ( 85045个结果
[Leetcode] Balanced Binary Tree
问题:给一个二叉树,写一个算法判断这个树是不是balanced。Solution #1.第一次遇到这个问题时我的解法,如下:public class Solution { public boolean isBalanced(TreeNode root) { if(root == ...
分类:其他好文   时间:2014-05-05 12:50:49    阅读次数:263
travel the binary tree by level 2 ( from top to down )
travel the binary tree by level 2 ( from top to down ) 个人信息:就读于燕大本科软件工程专业 目前大三; 本人博客:google搜索“cqs_2012”即可; 个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献; 博客内容:travel the binary tree by level 2 (...
分类:其他好文   时间:2014-05-04 09:27:56    阅读次数:334
SPFA(模板)
转载请注明出处: #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define pi acos(-1....
分类:其他好文   时间:2014-05-04 09:25:24    阅读次数:303
简单概率DP——hdu4405
题目描述: Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six faces with equal probability to...
分类:其他好文   时间:2014-05-04 09:18:42    阅读次数:321
travel the binary tree by level( from top to down)
travel the binary tree by level( from top to down) 个人信息:就读于燕大本科软件工程专业 目前大三; 本人博客:google搜索“cqs_2012”即可; 个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献; 博客内容:travel the binary tree by level( from top t...
分类:其他好文   时间:2014-05-04 09:17:12    阅读次数:292
Dijkstra算法求最短路径
Dijkstra算法,单源最短路径...
分类:其他好文   时间:2014-05-04 09:15:44    阅读次数:241
travel the binary tree by level 3 ( from down to top and from right to left every level )
travel the binary tree by level 3 ( from down to top ) 个人信息:就读于燕大本科软件工程专业 目前大三; 本人博客:google搜索“cqs_2012”即可; 个人爱好:酷爱数据结构和算法,希望将来从事算法工作为人民作出自己的贡献; 博客内容:travel the binary tree by level 3 ( f...
分类:其他好文   时间:2014-05-04 09:00:55    阅读次数:294
python数据结构与算法 35 快速排序
快速排序 快速排序也使用了分而治之的策略来提高性能,而且不需要额外的内存,但是这么做的代价就是,列表不是对半切分的,因而,性能上就有所下降。 快速排序选择一个数值,一般称为“轴点”,虽然有很多选取轴点的方法,我们还是简单地把列表中第一个元素做为轴点了。轴点的作用是帮助把列表分为两个部分。列表完成后,轴点所在的位置叫做“切分点”,从这一点上把列表分成两部分供后续调用。 图12所示,54将作...
分类:编程语言   时间:2014-05-04 08:59:00    阅读次数:388
codechef - Discrepancies in the Voters List 题解
codechef的本题算法也不难,但是codechef喜欢大数据,动不动就过万过十万,输入输出处理不好就会超时。 就像本题最大数据可能达到15万个整数。普通输入输出铁定超时了。 这里使用fread和fwrite这两个函数,设置好buffer,速度还是相当快的,而且相对很多程序都比较简单的了。 主要注意: 每个buffer数据块和下一个buffer数据块之间的衔接,不能破坏了最终需要...
分类:其他好文   时间:2014-05-04 08:54:04    阅读次数:268
uva 10635 Prince and Princess(LCS问题转化成LIS问题O(nlogn))
最长公共子序列经典问题,由于题的条件特殊,可转换成LIS问题,可在O(nlogn)内得到解决。根据刘汝佳大大的,加上自己的理解,不太理解的童鞋可以看一看(前提:已掌握LIS问题和LCS问题的解法)...
分类:其他好文   时间:2014-05-04 08:46:48    阅读次数:339
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!