PTA-中国大学MOOC-陈越、何钦铭-数据结构-2019春
文章平均质量分 92
centralunit
这个作者很懒,什么都没留下…
展开
-
01-复杂度1 最大子列和问题(20 分)
01-复杂度1 最大子列和问题(20 分)给定KKK个整数组成的序列{N1,N2,…,NK}\{ N_1, N_2, \dots, N_K \}{N1,N2,…,NK},“连续子列”被定义为{Ni,Ni+1,…,Nj}\{ N_i, N_{i+1}, \dots, N_j \}{Ni,Ni+1,…,Nj},其中1≤i≤j≤K1≤i≤j≤K1≤i≤j≤K。“最大子列和”则被定义为所有连...原创 2019-03-08 22:20:44 · 1163 阅读 · 0 评论 -
04-树5 Root of AVL Tree(25 分)
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 differ by at most one; if at any time they differ by ...原创 2019-04-20 20:58:27 · 1048 阅读 · 0 评论 -
04-树4 是否同一棵二叉搜索树(25 分)
04-树4 是否同一棵二叉搜索树(25 分)给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数N(≤10)N...原创 2019-04-20 20:52:29 · 2667 阅读 · 0 评论 -
03-树3 Tree Traversals Again(25 分)
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 ...原创 2019-04-20 20:46:36 · 510 阅读 · 1 评论 -
03-树2 List Leaves(25 分)
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, t...原创 2019-04-08 16:29:48 · 489 阅读 · 0 评论 -
03-树1 树的同构(25 分)
03-树1 树的同构(25 分)给定两棵树T1和T2。如果T1可以通过若干次左右孩子互换就变成T2,则我们称两棵树是“同构”的。例如图1给出的两棵树就是同构的,因为我们把其中一棵树的结点A、B、G的左右孩子互换后,就得到另外一棵树。而图2就不是同构的。图1图2现给定两棵树,请你判断它们是否是同构的。输入格式:输入给出2棵二叉树树的信息。对于每棵树,首先在一行中给出一个非负整数N(≤...原创 2019-04-08 16:26:15 · 2453 阅读 · 0 评论 -
02-线性结构4 Pop Sequence(25 分)
02-线性结构4 Pop Sequence(25 分)Given a stack which can keep MMM numbers at most. Push NNN numbers in the order of 1, 2, 3, …, NNN and pop randomly. You are supposed to tell if a given sequence of numbers...原创 2019-03-13 13:26:30 · 2358 阅读 · 0 评论 -
02-线性结构3 Reversing Linked List(25 分)
02-线性结构3 Reversing Linked List (25 分)Given a constant KKK and a singly linked list LLL, you are supposed to reverse the links of every KKK elements on LLL. For example, given LLL being 1→2→3→4→5→6, i...原创 2019-03-13 13:23:01 · 3311 阅读 · 2 评论 -
02-线性结构2 一元多项式的乘法与加法运算(20 分)
02-线性结构2 一元多项式的乘法与加法运算 (20 分)设计函数分别求两个一元多项式的乘积与和。输入格式:输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。输出格式:输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应...原创 2019-03-09 12:15:20 · 406 阅读 · 0 评论 -
02-线性结构1 两个有序链表序列的合并(15 分)
02-线性结构1 两个有序链表序列的合并(15 分)本题要求实现一个函数,将两个链表表示的递增整数序列合并为一个非递减的整数序列。函数接口定义:List Merge( List L1, List L2 );其中List结构定义如下:typedef struct Node *PtrToNode;struct Node { ElementType Data; /* 存储结点数据 ...原创 2019-03-08 22:44:12 · 444 阅读 · 0 评论 -
01-复杂度3 二分查找(20 分)
01-复杂度3 二分查找 (20 分)本题要求实现二分查找算法。函数接口定义:Position BinarySearch( List L, ElementType X );其中List结构定义如下:typedef int Position;typedef struct LNode *List;struct LNode { ElementType Data[MAXSIZE];...原创 2019-03-08 22:37:32 · 1096 阅读 · 0 评论 -
01-复杂度2 Maximum Subsequence Sum(25 分)
01-复杂度2 Maximum Subsequence Sum (25 分)Given a sequence of KKK integers {N1,N2,…,NK}\{ N_1, N_2, \dots, N_K \}{N1,N2,…,NK}. A continuous subsequence is defined to be {Ni,Ni+1,…,Nj}\{ N_i, N_{i+1}, ...原创 2019-03-08 22:28:13 · 753 阅读 · 0 评论 -
04-树6 Complete Binary Search Tree(30 分)
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...原创 2019-04-20 21:03:58 · 1300 阅读 · 0 评论