
MOOC浙大数据结构
文章平均质量分 84
石前有座桥
学生
展开
-
1089. Insert or Merge (25)
1089. Insert or Merge (25)时间限制200 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAccording to Wikipedia:Insertion sort原创 2017-05-04 11:43:13 · 283 阅读 · 0 评论 -
04-树4 是否同一棵二叉搜索树 (25分)
给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数NN (\le 10≤10)和LL,分别是每原创 2017-05-07 21:02:10 · 258 阅读 · 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 from one computer to another. Is it possible to send a file from any computer原创 2017-05-07 20:50:02 · 309 阅读 · 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 left subtree of a node contains only nodes with keys less than the node's key.转载 2017-05-09 10:44:55 · 297 阅读 · 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 input file contains one test case. For each case, the first line give转载 2017-05-09 10:55:52 · 262 阅读 · 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 when a 6-node binary tree (with the keys numbered from 1 to 6) is traversed, the stac原创 2017-05-09 11:02:27 · 200 阅读 · 0 评论 -
02-线性结构4 Pop Sequence (25分)
Given a stack which can keep MM numbers at most. Push NN numbers in the order of 1, 2, 3, ..., NN and pop randomly. You are supposed to tell if a given sequence of numbers is a possible pop sequ转载 2017-05-09 11:33:50 · 248 阅读 · 0 评论 -
02-线性结构1 两个有序链表序列的合并 (15分)
本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。函数接口定义:List Merge( List L1, List L2 );其中List结构定义如下:typedef struct Node *PtrToNode;struct Node { ElementType Data; /* 存储结点数据 */ PtrToNode原创 2017-05-09 11:38:08 · 351 阅读 · 0 评论 -
04-树7 二叉搜索树的操作集 (30分)
本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTree BST原创 2017-05-15 15:31:48 · 388 阅读 · 0 评论 -
1066. Root of AVL Tree (25)
时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAn AVL tree is a self-balancing binary search tree. In an AVL tree, the heig转载 2017-05-31 17:29:54 · 280 阅读 · 0 评论 -
1078. Hashing (25)
时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueThe task of this problem is simple: insert a sequence of distinct positive i转载 2017-05-20 15:17:56 · 188 阅读 · 0 评论 -
05-树7 堆中的路径 (25分)
将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。输入格式:每组测试第1行包含2个正整数NN和MM(\le 1000≤1000),分别是插入元素的个数、以及需要打印的路径条数。下一行给出区间[-10000, 10000]内的NN个要被插入一个初始为空的小顶堆的整数。最后一行给出MM个下标。输出格式:对输入中原创 2017-05-07 20:40:54 · 666 阅读 · 1 评论 -
07-图5 Saving James Bond - Hard Version (30分)
This time let us consider the situation in the movie "Live and Let Die" in which James Bond, the world's most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land原创 2017-05-07 15:25:19 · 1597 阅读 · 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 most famous spy, was captured by a group of drug dealers. He was sent to a small piece of land原创 2017-05-06 16:55:12 · 287 阅读 · 0 评论 -
1075 PAT Judge (25)
1075. PAT Judge (25)The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.Input Specif原创 2017-05-03 19:40:46 · 1333 阅读 · 3 评论 -
1098. Insertion or Heap Sort (25)
1098. Insertion or Heap Sort (25)时间限制100 ms内存限制65536 kB代码长度限制16000 B判题程序Standard作者CHEN, YueAccording to Wikipedia:Insertio原创 2017-05-04 15:08:32 · 265 阅读 · 0 评论 -
08-图7 公路村村通 (30分)
08-图7 公路村村通 (30分)现有村落间道路的统计数据表中,列出了有可能建设成标准公路的若干条道路的成本,求使每个村落都有公路连通所需要的最低成本。输入格式:输入数据包括城镇数目正整数NN(\le 1000≤1000)和候选道路数目MM(\le 3N≤3N);随后的MM行对应MM条道路,每行给出3个正整数,分别是该条道路直接连通的两个城镇的编号以及该道路原创 2017-05-04 15:25:27 · 542 阅读 · 0 评论 -
08-图8 How Long Does It Take (25分)
Given the relations of all the activities of a project, you are supposed to find the earliest completion time of the project.Input Specification:Each input file contains one test case. Each ca原创 2017-05-04 15:32:53 · 497 阅读 · 0 评论 -
08-图9 关键活动 (30分)
08-图9 关键活动 (30分)假定一个工程项目由一组子任务构成,子任务之间有的可以并行执行,有的必须在完成了其它一些子任务后才能执行。“任务调度”包括一组子任务、以及每个子任务可以执行所依赖的子任务集。比如完成一个专业的所有课程学习和毕业设计可以看成一个本科生要完成的一项工程,各门课程可以看成是子任务。有些课程可以同时开设,比如英语和C程序设计,它们没有必须先修哪门的原创 2017-05-05 10:19:24 · 837 阅读 · 2 评论 -
11-散列4 Hashing - Hard Version (30分)
11-散列4 Hashing - Hard Version (30分)Given a hash table of size NN, we can define a hash function . Suppose that the linear probing is used to solve collisions, we can easily obtain the stat转载 2017-05-24 18:34:47 · 1081 阅读 · 2 评论 -
07-图4 哈利·波特的考试 (25分)
哈利·波特要考试了,他需要你的帮助。这门课学的是用魔咒将一种动物变成另一种动物的本事。例如将猫变成老鼠的魔咒是haha,将老鼠变成鱼的魔咒是hehe等等。反方向变化的魔咒就是简单地将原来的魔咒倒过来念,例如ahah可以将老鼠变成猫。另外,如果想把猫变成鱼,可以通过念一个直接魔咒lalala,也可以将猫变老鼠、老鼠变鱼的魔咒连起来念:hahahehe。现在哈利·波特的手里有一本教材,里面列出原创 2017-05-05 16:54:13 · 458 阅读 · 0 评论 -
06-图1 列出连通集 (25分)
给定一个有NN个顶点和EE条边的无向图,请用DFS和BFS分别列出其所有的连通集。假设顶点从0到N-1N−1编号。进行搜索时,假设我们总是从编号最小的顶点出发,按编号递增的顺序访问邻接点。输入格式:输入第1行给出2个整数NN(0<N\le 100N≤10)和EE,分别是图的顶点数和边数。随后EE行,每行给出一条边的两个端点。每行中的数字之间用1空格分隔。输出格式:原创 2017-05-05 17:11:28 · 347 阅读 · 0 评论 -
06-图3 六度空间 (30分)
“六度空间”理论又称作“六度分隔(Six Degrees of Separation)”理论。这个理论可以通俗地阐述为:“你和任何一个陌生人之间所间隔的人不会超过六个,也就是说,最多通过五个人你就能够认识任何一个陌生人。”如图1所示。图1 六度空间示意图“六度空间”理论虽然得到广泛的认同,并且正在得到越来越多的应用。但是数十年来,试图验证这个理论始终是许多社会学家努力追求的目标原创 2017-05-05 17:56:09 · 321 阅读 · 0 评论 -
11-散列1 电话聊天狂人 (25分)
11-散列1 电话聊天狂人 (25分)给定大量手机用户通话记录,找出其中通话次数最多的聊天狂人。输入格式:输入首先给出正整数NN(\le 10^5≤105),为通话记录条数。随后NN行,每行给出一条通话记录。简单起见,这里只列出拨出方和接收方的11位数字构成的手机号码,其中以空格分隔。输出格式:在一行中给出聊天狂人的手机号码及其通话次数,其间以转载 2017-05-25 18:24:08 · 581 阅读 · 0 评论 -
11-散列3 QQ帐户的申请与登陆
11-散列3 QQ帐户的申请与登陆 (25分)实现QQ新帐户申请和老帐户登陆的简化版功能。最大挑战是:据说现在的QQ号码已经有10位数了。输入格式:输入首先给出一个正整数NN(\le 10^5≤105),随后给出NN行指令。每行指令的格式为:“命令符(空格)QQ号码(空格)密码”。其中命令符为“N”(代表New)时表示要新申请一个QQ号,后面是新帐户的号码转载 2017-05-20 16:35:33 · 465 阅读 · 1 评论