码迷,mamicode.com
首页 > 2014年11月27日 > 全部分享
CC150 4.1
4.1Implementafunctiontocheckifatreeisbalanced.Forthepurposesofthisquestion,abalancedtreeisdefinedtobeatreesuchthatnotwoleafnodesdifferindistancefromtherootbymorethanone.Abalancedtree?http://en.wikipedia.org/wiki/Self-balancing_binary_search_treeIteratethetr..
分类:其他好文   时间:2014-11-27 08:03:52    阅读次数:190
CC150 4.2
4.2Givenadirectedgraph,designanalgorithmtofindoutwhetherthereisaroutebetweentwonodes.Node { List<Node>neighbours; } booleanisConnected(Nodefrom,Nodeto) { Stack<Node>toVisit=initStack(); Set<Node>seen=initSet(); toVisit.push(from); while..
分类:其他好文   时间:2014-11-27 08:05:32    阅读次数:147
电脑日常状态(电脑配置:i5-3210M,8G内存,nvida630显卡;64位的win7旗舰版系统)
启动后台自起Foxmail,搜狗输入法,腾讯qq(2),360安全卫士,360杀毒,VMware虚拟机服务;此时进程数50,cpu使用率最高2%(最低0%);物理内存19%。
分类:Windows程序   时间:2014-11-27 08:04:53    阅读次数:223
CC150 4.3
4.3Givenasorted(increasingorder)array,writeanalgorithmtocreateabinarytreewithminimalheight.[1,2,4,5,6]CreateaBTwithminheight.=>balancedtree.Nodebuild(intarray) { returnbuild(array,0,array.length-1,null); } O(logn) privateNodebuild(int[]array,intfrom,int..
分类:其他好文   时间:2014-11-27 08:04:10    阅读次数:189
CC150 4.4
4.4Givenabinarysearchtree,designanalgorithmwhichcreatesalinkedlistofallthenodesateachdepth(i.e.,ifyouhaveatreewithdepthD,you’llhaveDlinkedlists).List<List<Node>>build(Noderoot) { List<List<Node>>toReturn=initList(); build(root,0,toR..
分类:其他好文   时间:2014-11-27 08:02:53    阅读次数:189
CC150 4.5
4.5Writeanalgorithmtofindthe‘next’node(i.e.,in-ordersuccessor)ofagivennodeinabinarysearchtreewhereeachnodehasalinktoitsparent.//BST. classNode { Nodeparent; Nodeleft; Noderight; } Nodemin(Nodenode) { if(node==null) returnnull; while(node.left!=null) nod..
分类:其他好文   时间:2014-11-27 08:01:56    阅读次数:218
CC150 4.6
4.6Designanalgorithmandwritecodetofindthefirstcommonancestoroftwonodesinabinarytree.Avoidstoringadditionalnodesinadatastructure.NOTE:Thisisnotnecessarilyabinarysearchtree.BTNodefind(Noden,Nodea,Nodeb) { if(n==a||n==b) { returnn; } intnodeMatch=nodeMatch(a...
分类:其他好文   时间:2014-11-27 08:02:42    阅读次数:180
Linux消息队列基础
消息队列基本概念    消息队列提供了一个从一个进程向另外一个进程发送一块数据的方法(仅局限与本机)    每个数据块都被认为是有一个类型,接收者进程接收的数据块可以有不同的类型值    消息队列也有管道一样的不足,就是每个消息的最大长度是有上限的(MSGMAX),每个消息队列的总的字节数是有上限的(MSGMNB),系统上消息队列的总数也有一个上限(MSGMNI) 管道 vs. 消息队列:管道: ...
分类:系统相关   时间:2014-11-27 08:03:21    阅读次数:366
Struts2之拦截器原理分析及使用-中
a)在这里要提一下设计模式。设计模式是对一些特定场景实现代码的设计经验总结。在Java中有大概有23种吧,当然不是说让大家都熟练掌握,说实话,我现在也就了解那么几种,实际应用也没怎么使过。大家只需简单了解下就行。毕竟对自身编码会有好处的。 b)我们只要理解过滤器就很容易理解拦截器,无论是设计原理、设计模式还是实现方式上两者都是一样的,区别在于过滤器可以过滤一切东西,拦截器只能拦截action,因为我们只能在action上配置拦截器。 c)当我们编写代码时,要养成写注释的习惯。这个很重要,不只是为了让我们...
分类:其他好文   时间:2014-11-27 08:03:55    阅读次数:181
P2P需展现其更适宜平民化理财的属性
近年来,P2P网贷呈现了迅猛发展的态势,作为互联网金融的重大突破,这一创新模式不仅获得了国家政策的支持和鼓励,更重要的是,通过不断的宣传和推广,越来越多普通老百姓也开始深入了解P2P网贷,包括三四线城市甚至农村的投资者,也对P2P网贷表现出浓厚的兴趣。     众所周知,要让三四线城市甚至农村的投资者也接受P2P网贷并非一件容易的事情,因为上述区域经济不如一二线城市发达,老百姓了...
分类:其他好文   时间:2014-11-27 08:02:33    阅读次数:192
bzoj 1023: [SHOI2008]cactus仙人掌图 tarjan索环&&环上单调队列
1023: [SHOI2008]cactus仙人掌图Time Limit:1 SecMemory Limit:162 MBSubmit:1141Solved:435[Submit][Status]Description如果某个无向连通图的任意一条边至多只出现在一条简单回路(simple cycle)...
分类:其他好文   时间:2014-11-27 08:00:03    阅读次数:335
Tomcat源码分析之—组件启动实现分析
Tomcat由多个组件组成,那么Tomcat是怎么对他们的生命周期进行管理的么,这里将从Tomcat源码去分析其生命周期的实现;Bootstrape类为Tomcat的入口,所有的组件够通过实现Lifecycle接口来管理生命周期,Tomcat启动的时候只需调用Server容器的start(),然.....
分类:其他好文   时间:2014-11-27 08:02:10    阅读次数:279
Java并发(具体实例)——几个例子
一步步优化页面渲染功能 本节将模拟一个简单的页面渲染功能,它的作用是将HTML页面绘制到图像缓存中,为了简便,假设HTML文件只包含标签文本以及预订大小的图片和URL。1、串行的页面渲染器 最简单的实现方式是对HTML文档进行串行处理...
分类:编程语言   时间:2014-11-27 08:00:10    阅读次数:238
[Leetcode] Surrounded Regions
Given a 2D board containing'X'and'O', capture all regions surrounded by'X'.A region is captured by flipping all'O's into'X's in that surrounded region...
分类:其他好文   时间:2014-11-27 08:01:17    阅读次数:160
Tree Traversal
Basic Tree TraversalDepth First Traversal:1. In order traversal----left, root, right----4,2,5,1,32. Pre order traversal-----root, left, right-----1,2,...
分类:其他好文   时间:2014-11-27 07:59:38    阅读次数:232
[LeetCode] String to Integer (atoi) 字符串转为整数
Implement atoi to convert a string to an integer.Hint: Carefully consider all possible input cases. If you want a challenge, please do not see below a...
分类:其他好文   时间:2014-11-27 08:00:27    阅读次数:319
Leetcode-Longest Palindromic Substring
Given a string S, find the longest palindromic substring in S. You may assume that the maximum length of S is 1000, and there exists one unique longes...
分类:其他好文   时间:2014-11-27 07:59:55    阅读次数:184
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!