2019浙大数据结构PAT
2019浙大数据结构PAT-中国大学MOOC课程
chenmo2019
前端
展开
-
01-复杂度1 最大子列和问题 (20 分)
给定K个整数组成的序列{ N1, N2, …, NK},“连续子列”被定义为{ Ni, Ni+1, …, Nj},其中 1≤i≤j≤K。“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4, 13 }有最大的和20。现要求你编写程序,计算给定整数序列的最大子列和。 本题旨在测试各种不同的算法在各种...原创 2019-08-01 20:54:31 · 139 阅读 · 0 评论 -
09-排序1 排序 (25 分)
文章目录题目输入格式:输出格式:输入样例:输出样例:插入排序(Insertion_Sort)Code提交结果 题目 给定N个(长整型范围内的)整数,要求输出从小到大排序后的结果。 本题旨在测试各种不同的排序算法在各种数据情况下的表现。各组测试数据特点如下: 数据1:只有1个元素; 数据2:11个不相同的整数,测试基本正确性; 数据3:103个随机整数; 数据4:104个随机整数; 数据5:105个...原创 2019-08-26 22:25:48 · 198 阅读 · 0 评论 -
03-树1 树的同构 (25 分)
include <stdio.h> //Using struct arrays impresses double tree branches; #define MaxTree 10 #define ElementType char #define Tree int #define Null -1 // in the arrays,we can see it isn't pointer...原创 2019-08-17 16:24:50 · 117 阅读 · 0 评论 -
02-线性结构4 Pop Sequence (25 分)
文章目录Input Specification:Output Specification:Sample Input:Sample Output:Code Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, …, N and pop randomly. You are supp...原创 2019-08-25 10:20:46 · 222 阅读 · 0 评论 -
02-线性结构3 Reversing Linked List (25 分)
文章目录 #include<stdio.h> #define MAXLEN 100002 struct node { int data; int next; }; int k,head; struct node workArray [MAXLEN]; //结构数组 int Input(struct node array[]) { int i,inp...原创 2019-08-24 20:03:11 · 120 阅读 · 0 评论 -
堆栈的链表实现
#include<stdio.h> //程序结构 //首先接受输入(头结点位置,结点个数,翻转子表长度)。 //使用堆栈,先进后出。--堆栈的链式存储实现 //利用Length判断堆栈的pop时机。 typedef int ElemenTpye; typedef struct SNode *Stack; //Stack 堆栈 struct SNode{ ...原创 2019-08-24 12:45:27 · 279 阅读 · 0 评论 -
二叉树遍历
二叉树遍历 遍历是对树的一种最基本的运算,所谓遍历二叉树,就是按一定的规则和顺序走遍二叉树的所有结点,使每一个结点都被访问一次,而且只被访问一次。由于二叉树是非线性结构,因此,树的遍历实质上是将二叉树的各个结点转换成为一个线性序列来表示。 设L、D、R分别表示遍历左子树、访问根结点和遍历右子树, 则对一棵二叉树的遍历有三种情况:DLR(称为先根次序遍历),LDR(称为中根次序遍历),LRD (称为...原创 2019-08-15 10:40:37 · 114 阅读 · 0 评论 -
03-树2 List Leaves (25 分)
文章目录Input Specification:Output Specification:Sample Input:Sample Output:Code(C++)Code(C) Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specif...原创 2019-08-23 21:58:52 · 126 阅读 · 0 评论 -
02-线性结构2 一元多项式的乘法与加法运算 (20分)
#include <stdlib.h> #include <stdio.h> typedef struct PolyNode * Polynomail; struct PolyNode{ int coef; // 系数 int expon; //幂 Polynomail link; }; //声明结构体需要分号结尾 void Attac...原创 2019-08-14 16:50:24 · 111 阅读 · 0 评论 -
02-线性结构2 一元多项式的乘法与加法运算 (20 分)
文章目录题目代码 题目 设计函数分别求两个一元多项式的乘积与和。 输入格式: 输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。 输出格式: 输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。 输入样例: 4 3 4...原创 2019-08-07 16:07:31 · 124 阅读 · 0 评论 -
02-线性结构1 两个有序链表序列的合并 (15 分)
文章目录题目代码 题目 本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。 函数接口定义: List Merge( List L1, List L2 ); 其中List结构定义如下: typedef struct Node *PtrToNode; struct Node { ElementType Data; /* 存储结点数据 */ PtrToNod...原创 2019-08-07 16:05:44 · 190 阅读 · 0 评论 -
02-线性结构2 一元多项式的乘法与加法运算 (20 分)
数据结构设计 typedef struct PolyNode *Polynomail; struct PolyNode{ int coef; //系数 int expon; //幂 Polynomail link; //指向结构体本身的指针 }; 程序框架搭建 int main() { //读入多项式1 //读入多项式2 //两个多项式相加 ...原创 2019-08-08 23:33:16 · 160 阅读 · 0 评论 -
01-复杂度2 Maximum Subsequence Sum (25 分)
文章目录Input SpecificationOutput SpecificationSample InputSample Outputcode意外 Given a sequence of K integers { N1, N2, …, NK }. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj...原创 2019-08-06 17:58:47 · 103 阅读 · 0 评论 -
01-复杂度3 二分查找 (20 分)
文章目录题目代码 题目 本题要求实现二分查找算法。 函数接口定义: Position BinarySearch( List L, ElementType X ); 其中List结构定义如下: typedef int Position; typedef struct LNode *List; struct LNode { ElementType Data[MAXSIZE]; Pos...原创 2019-08-06 17:47:16 · 209 阅读 · 0 评论 -
03-树3 Tree Traversals Again (25 分)
文章目录Input Specification:Output Specification:Sample Input:Sample Output:Code An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6...原创 2019-09-03 17:45:05 · 117 阅读 · 0 评论