数据结构
文章平均质量分 64
一颗橡树
靡不有初,鲜克有终
展开
-
1007 Maximum Subsequence Sum (25分)
1007 Maximum Subsequence Sum (25分)Given a sequence of K integers { N1, N2, …, NK}. A continuous subsequence is defined to be { Ni, Ni+1, …, Nj} where 1≤i≤j≤K. The Maximum Subsequence is the cont...原创 2020-03-07 16:03:49 · 218 阅读 · 0 评论 -
1105 Spiral Matrix (25分)
1105 Spiral Matrix (25分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-...原创 2020-03-04 15:08:40 · 211 阅读 · 0 评论 -
1125 Chain the Ropes (25分)
1125 Chain the Ropes (25分)Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the...原创 2020-02-26 15:27:25 · 183 阅读 · 0 评论 -
PAT(Advancedlevel) 1033 To Fill or Not to Fill (25分)
1033 To Fill or Not to Fill (25分)With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the w...原创 2020-02-12 15:37:37 · 297 阅读 · 1 评论 -
二叉树:已知前序序列与后序序列建树
二叉树:已知前序与后序建树已知前序与中序、后序与中序建树是常遇到的算法问题。若已知前序序列与后序序列,要求输出满足条件的树的个数或者输出所有可能的树的中序序列,该怎么解决?下面我们一步步讨论这个问题。首先,已知一个树的结点数n,共有多少种树形?(或者,已知一颗树的先序/中序/后序序列,共有多少种树形?)答案是Cmn/(n+1)C_{m}^{n}/(n+1)Cmn/(n+1)种。点这里了解一...原创 2020-02-08 19:35:53 · 9784 阅读 · 12 评论 -
PAT (Advanced Level)1110 Complete Binary Tree (25分)
1110 Complete Binary Tree (25分)Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives...原创 2020-02-06 18:57:04 · 193 阅读 · 0 评论 -
PAT (Advanced Level)1104 Sum of Number Segments (20分)
1104 Sum of Number Segments (20分)Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segment...原创 2020-02-05 17:48:20 · 186 阅读 · 0 评论 -
PAT (Advanced Level)1105 Spiral Matrix (25分)
1105 Spiral Matrix (25分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the...原创 2020-02-05 17:33:04 · 256 阅读 · 0 评论 -
PAT (Advanced Level) 1010 Radix (25 分)
这道题的坑主要有下面几点:1、进制上界根据所给数的十进制大小确定,下界由最大数位决定。2、使用二分防止超时。3、二分时注意判断查找结果是否溢出(从某一进制转换为10进制时可能发生溢出)#include<bits/stdc++.h>using namespace std;typedef long long ll;string n1,n2;int tag;ll radi...原创 2019-11-11 23:09:03 · 271 阅读 · 1 评论 -
数据结构问题思考
1、错误背景:练习DS代码——将两个有序链表归并的算法int main(){Linklist *L1,*L2,*L3,*p;①L3 = (Linklist *)malloc(sizeof(Linklist));②L1 = IncreRearin();③IncreRearin(L2);Merge(L1,L2,L3);p = L3-&amp;amp;gt;next;while(p!=NULL){co...原创 2018-10-24 11:00:56 · 373 阅读 · 0 评论