上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页
摘要: 二叉树的非递归遍历 二叉树是一种非常重要的数据结构,很多其它数据结构都是基于二叉树的基础演变而来的。对于二叉树,有前序、中序以及后序三种遍历方法。因为树的定义本身就是递归定义,因此采用递归的方法去实现树的三种遍历不仅容易理解而且代码很简洁。而对于树的遍历若采用非递归的方法,就要采用栈去模拟... 阅读全文
posted @ 2014-07-30 20:33 冷夏的博客园 阅读(89) 评论(0) 推荐(0) 编辑
摘要: DescriptionLittle Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital l... 阅读全文
posted @ 2014-07-30 19:32 冷夏的博客园 阅读(311) 评论(0) 推荐(0) 编辑
摘要: DescriptionBackgroundBinary trees are a common data structure in computer science. In this problem we will look at an infinite binary tree where the n... 阅读全文
posted @ 2014-07-30 18:30 冷夏的博客园 阅读(362) 评论(0) 推荐(0) 编辑
摘要: A -Tree Grafting(9.1.1)Time Limit:5000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionTrees have many applications in comput... 阅读全文
posted @ 2014-07-30 18:01 冷夏的博客园 阅读(280) 评论(0) 推荐(0) 编辑
摘要: A -敌兵布阵Time Limit:1000MSMemory Limit:32768KB64bit IO Format:%I64d & %I64uSubmitStatusDescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸... 阅读全文
posted @ 2014-07-30 10:58 冷夏的博客园 阅读(93) 评论(0) 推荐(0) 编辑
摘要: Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个测试用例的... 阅读全文
posted @ 2014-07-29 19:49 冷夏的博客园 阅读(159) 评论(0) 推荐(0) 编辑
摘要: DescriptionSevere acute respiratory syndrome (SARS), an atypical pneumonia of unknown aetiology, was recognized as a global threat in mid-March 2003. ... 阅读全文
posted @ 2014-07-29 19:02 冷夏的博客园 阅读(150) 评论(0) 推荐(0) 编辑
摘要: DescriptionThere are so many different religions in the world today that it is difficult to keep track of them all. You are interested in finding out ... 阅读全文
posted @ 2014-07-28 16:55 冷夏的博客园 阅读(133) 评论(0) 推荐(0) 编辑
摘要: DescriptionProblem IFriendsThere is a town with N citizens. It is known that some pairs of people are friends. According to the famous saying that “Th... 阅读全文
posted @ 2014-07-28 16:38 冷夏的博客园 阅读(157) 评论(0) 推荐(0) 编辑
摘要: 有一棵二叉树,最大深度为D,且所有叶子的深度都相同。所有结点从上到下从左到右编号为1,2,3,...,2^D-1。在结点1处放一个小球,它会往下落。每个内结点上都有一个开关,初始全部关闭,当每次有小球落到一个开关上时,它的状态都会改变。当小球到达一个内结点时,如果该结点上的开关关闭,则往左走,否者往... 阅读全文
posted @ 2014-07-27 21:07 冷夏的博客园 阅读(371) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 ··· 12 下一页