摘要: Description在众多的数据结构中,二叉树是一种特殊而重要的结构,有着广泛的应用。二叉树或者是一个结点,或者有且仅有一个结点为二叉树的根,其余结点被分成两个互不相交的子集,一个作为左子集,另一个作为右子集,每个子集又是一个二叉树。遍历一棵二叉树就是按某条搜索路径巡访其中每个结点,使得每个结点均被访问一次,而且仅被访问一次。最常使用的有三种遍历的方式:1.前序遍历:若二叉树为空,则空操作;否则先访问根结点,接着前序遍历左子树,最后再前序遍历右子树。2.中序遍历:若二叉树为空,则空操作;否则先中序遍历左子树,接着访问根结点,最后再前中遍历右子树。3.后序遍历:若二叉树为空,则空操作;否则先后 阅读全文
posted @ 2013-01-25 15:54 Cielsk 阅读(361) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe ministers of the cabinet were quite upset by the message from the Chief of Security stating that they would all have to change the four-digit room numbers on their offices.— It is a matter of security to change such things every now and then, to keep the enemy in the dark.— But look, 阅读全文
posted @ 2013-01-25 15:53 Cielsk 阅读(186) 评论(0) 推荐(0) 编辑
摘要: Description在一个神秘的国度里,年轻的王子Paris与美丽的公主Helen在一起过着幸福的生活。他们都随身带有一块带磁性的阴阳魔法石,身居地狱的魔王Satan早就想得到这两块石头了,只要把它们熔化,Satan就能吸收其精华大增自己的魔力。于是有一天他趁二人不留意,把他们带到了自己的地牢,分别困在了不同的地方。然后Satan念起了咒语,准备炼狱,界时二人都将葬身于这地牢里。危险!Paris与Helen都知道了Satan的意图,他们要怎样才能打败魔王,脱离地牢呢?Paris想起了父王临终前留给他的备忘本,原来他早已料到了Satan的野心,他告诉Paris只要把两块魔法石合在一起,念出咒语 阅读全文
posted @ 2013-01-25 15:52 Cielsk 阅读(229) 评论(0) 推荐(0) 编辑
摘要: DescriptionThe game of ‘Inverso’ is played on a 3x3 grid of colored fields (each field is either black or white). Each field is numbered as follows:1 2 34 5 67 8 9The player can click on a field, which will result in the inversion of that field and all its direct neighboring fields (i.e. the color c 阅读全文
posted @ 2013-01-25 15:49 Cielsk 阅读(304) 评论(0) 推荐(0) 编辑
摘要: DescriptionIn the field of computer science, forest is important and deeply researched , it is a model for many data structures . Now it’s your job here to calculate the depth and width of given forests.Precisely, a forest here is a directed graph with neither loop nor two edges pointing to the same 阅读全文
posted @ 2013-01-25 15:48 Cielsk 阅读(323) 评论(0) 推荐(0) 编辑
摘要: DescriptionLenny likes to play the game of lotto. In the lotto game, he picks a list ofNunique numbers in the range from1toM. If his list matches the list of numbers that are drawn, he wins the big prize.Lenny has a scheme that he thinks is likely to be lucky. He likes to choose his list so that eac 阅读全文
posted @ 2013-01-25 15:47 Cielsk 阅读(188) 评论(0) 推荐(0) 编辑
摘要: DescriptionIrv Kenneth Diggit works for a company that excavates trenches, digs holes and generally tears up people's yards. Irv's job is to make sure that no underground pipe or cable is underneath where excavation is planned. He has several different maps, one for each utility company, sho 阅读全文
posted @ 2013-01-25 15:46 Cielsk 阅读(394) 评论(0) 推荐(0) 编辑
摘要: DescriptionGiven a sequence of consecutive integers n,n+1,n+2,...,m, an anti-prime sequence is a rearrangement of these integers so that each adjacent pair of integers sums to a composite (non-prime) number. For example, if n = 1 and m = 10, one such anti-prime sequence is 1,3,5,4,2,6,9,7,8,10. This 阅读全文
posted @ 2013-01-25 15:45 Cielsk 阅读(197) 评论(0) 推荐(0) 编辑
摘要: DescriptionAt present, Zhongshan University has 4 campuses with a total area of 6.17 square kilometers sitting respectively on both sides of the Pearl River or facing the South China Sea. The Guangzhou South Campus covers an area of 1.17 square kilometers, the North Campus covers an area of 0.39 squ 阅读全文
posted @ 2013-01-25 15:43 Cielsk 阅读(329) 评论(0) 推荐(0) 编辑
摘要: DescriptionThere are N cities and N-1 roads in Magic-Island. You can go from one city to any other. One road only connects two cities. One day, The king of magic-island want to visit the island from the capital. No road is visited twice. Do you know the longest distance the king can go.InputThere ar 阅读全文
posted @ 2013-01-25 15:42 Cielsk 阅读(304) 评论(0) 推荐(0) 编辑