摘要: 06-图3 六度空间(30 分) “六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。 图1 六度空间示意图 “六度空 阅读全文
posted @ 2017-12-18 09:32 A-Little-Nut 阅读(1657) 评论(0) 推荐(0) 编辑
摘要: 06-图2 Saving James Bond - Easy Version(25 分) This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's 阅读全文
posted @ 2017-12-18 09:28 A-Little-Nut 阅读(197) 评论(0) 推荐(0) 编辑
摘要: 06-图1 列出连通集(25 分) 给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。 给定一个有N个顶点和E条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶 阅读全文
posted @ 2017-12-18 09:26 A-Little-Nut 阅读(389) 评论(0) 推荐(0) 编辑
摘要: 05-树8 File Transfer(25 分) We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer fr 阅读全文
posted @ 2017-12-18 09:24 A-Little-Nut 阅读(406) 评论(0) 推荐(0) 编辑
摘要: 05-树7 堆中的路径(25 分) 将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。 将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。 将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任 阅读全文
posted @ 2017-12-18 09:23 A-Little-Nut 阅读(239) 评论(0) 推荐(0) 编辑
摘要: 04-树6 Complete Binary Search Tree(30 分) A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties: The lef 阅读全文
posted @ 2017-12-18 09:21 A-Little-Nut 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 04-树5 Root of AVL Tree(25 分) An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node dif 阅读全文
posted @ 2017-12-18 09:11 A-Little-Nut 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 04-树4 是否同一棵二叉搜索树 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜 阅读全文
posted @ 2017-12-18 09:09 A-Little-Nut 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 03-树3 Tree Traversals Again(25 分) An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that w 阅读全文
posted @ 2017-12-18 09:05 A-Little-Nut 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 03-树2 List Leaves(25 分) Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specification: Each i 阅读全文
posted @ 2017-12-18 09:03 A-Little-Nut 阅读(159) 评论(0) 推荐(0) 编辑