数据结构:链表
leslie___
越努力越幸运
展开
-
浙大数据结构02-线性结构4 Pop Sequence (25分) 模拟栈
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 supposed to tell if a given sequence of numbers is a possible pop sequence of the...原创 2020-04-17 11:02:50 · 398 阅读 · 0 评论 -
浙大数据结构02-线性结构3 Reversing Linked List (25分)
Given a constant K and a singly linked list L, you are supposed to reverse the links of every K elements on L. For example, given L being 1→2→3→4→5→6, if K=3, then you must output 3→2→1→6→5→4; if K=4,...原创 2020-04-17 10:49:55 · 500 阅读 · 1 评论 -
浙大数据结构02-线性结构2 一元多项式的乘法与加法运算 (20分)
设计函数分别求两个一元多项式的乘积与和。 输入格式: 输入分2行,每行分别先给出多项式非零项的个数,再以指数递降方式输入一个多项式非零项系数和指数(绝对值均为不超过1000的整数)。数字间以空格分隔。 输出格式: 输出分2行,分别以指数递降方式输出乘积多项式以及和多项式非零项的系数和指数。数字间以空格分隔,但结尾不能有多余空格。零多项式应输出0 0。 输入样例: 4 3 4 -5 2 6 1 ...原创 2020-04-17 09:59:23 · 455 阅读 · 0 评论 -
浙大数据结构02-线性结构1 两个有序链表序列的合并
L1和L2是给定的带头结点的单链表,其结点存储的数据是递增有序的;函数Merge要将L1和L2合并为一个非递减的整数序列。应直接使用原序列中的结点,返回归并后的带头结点的链表头指针。 输入样例: 3 1 3 5 5 2 4 6 8 10 输出样例: 1 2 3 4 5 6 8 10 NULL NULL #include <iostream> #include <cstdlib&g...原创 2020-04-17 09:36:53 · 241 阅读 · 0 评论