- 博客(58)
- 收藏
- 关注
原创 线性结构4 Pop Sequence
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, ..., Nand pop randomly. You are supposed to tell if a given sequence of
2017-11-27 18:27:54
261
原创 Maximum Subsequence Sum
01-复杂度2 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
2017-11-27 18:23:28
281
原创 最大子列和问题
01-复杂度1 最大子列和问题(20 分)给定K个整数组成的序列{ N1, N2, ..., NK },“连续子列”被定义为{ Ni, Ni+1, ..., Nj },其中 1≤i≤j≤K。“最大子列和”则被定义为所有连续子列元素的和中最大者。例如给定序列{ -2, 11, -4, 13, -5, -2 },其连续子列{ 11, -4
2017-11-27 18:21:22
310
原创 图4 哈利·波特的考试
#includeusing namespace std;#define Maxsize 101struct enode{int v1,v2;int weight;};using edge=enode*; struct graph{int Nv;int Ne;int G[Maxsize][Maxsize];};using Graph=graph*;
2017-11-27 18:18:23
328
原创 Huffman codes
这个程序我花了不少时间,改改,找错误,放弃,重写。只能 说细节很多,感觉每个程序 都不是那么简单,需要自己 默默地付出许多。 #include#includeusing namespace std;#define maxsize 64struct node{int weight=-1;node* l=NULL;node* r=NULL;};using haf
2017-11-26 16:21:24
372
原创 Saving James Bond - Hard Version
#include#include#include#include#includeusing namespace std;#define Maxnodenum 101#define nolimitmax 100000int flag=0;//为了标志第一次拓展外层vector dist(Maxnodenum,nolimitmax);//为了记住跳到每个点的步数
2017-11-26 11:05:31
378
原创 六度空间
本来编程时,结果如下测试点提示结果耗时内存0sample 简单一条链答案正确2 ms372KB1不连通答案正确2 ms384KB2一般图答案正确2 ms372KB3最小N和M答案正确2 ms3
2017-11-26 09:23:04
1104
原创 Saving James Bond - Easy Version
#include#include #includeusing namespace std;#define MaxN 101int flag=0;vector visited(MaxN,0);struct node{int x;int y;};struct Gnode{int N;int D;node G[MaxN];};using G
2017-11-23 13:07:33
289
原创 列出连通集
#include#include#includeusing namespace std;#define maxvertexnum 10 #define weighttype int#define datatype string#define vertex intstruct graph{int Nv;//定点数 int Ne;//边数weighttype
2017-11-23 11:02:43
439
原创 File Transfer(25 分)
本题还可以做路径压缩等优化,本人并没有,请见陈 越老师详解#include#includeusing namespace std;struct node{int data;int parent=-1;};int size;int Find(vector &set,int data){int q=data-1;while(set[q].parent>0)
2017-11-20 20:55:15
461
原创 堆中的路径
#include#includeusing namespace std;#define MAXSIZE 1001#define Min -10001int H[MAXSIZE],size;void create(){size=0;H[0]=Min;}void Insert(int t){int i;for(i=++size;H[i/2]>t;i/=2
2017-11-20 18:36:00
303
原创 Complete Binary Search Tree
这道题就我所知道已经有两种解法了:第一种: 比较繁琐,我自己也是这么思考的,但实现过程太繁琐以及自己对递归的掌握不好,在编程中放弃了,结果看了陈越老师的思路竟然和我一样,可能这个思考过程更一般吧,利用了搜索树的 任意节点的左边的节点都小于该节点,右边节点都大于该节点以及已知节点数可知完整的二叉搜索树的结构来确定节点的;总的老说,思路简单,实现复杂;#include #include
2017-11-19 18:43:32
346
原创 Root of AVL Tree(25 分)
参考了www.dongjinbao.com觉得做法很巧妙,简洁。十分佩服!觉得自己还不能充分理解递归!!!!#includeusing namespace std;struct treenode{int data,h;treenode* left=NULL;treenode* right=NULL;};using tree=treenode*;int hei
2017-11-18 12:50:21
477
原创 04-树4 是否同一棵二叉搜索树(25 分)
给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。输入格式:输入包含若干组测试数据。每组数据的第1行给出两个正整数N (≤)和L,分别是每个序列插入元素的个数和需
2017-11-18 09:27:55
483
原创 03-树3 Tree Traversals Again(25 分)
用了一个enum顺利解决了问题#include#includeusing namespace std;enum State{return_from_left,return_from_right};struct treenode{int data;treenode* left;treenode* right;enum State state;};using
2017-11-16 21:05:12
274
原创 03-树2 List Leaves(25 分)
用的是层序遍历#include#include#include#include#define maxsize 10#define tree int #define Null -1using namespace std;int tag=1;struct treenode{int left;int right;}t[maxsize];tree t
2017-11-16 19:08:10
340
原创 Reversing Linked List
版本一:用链表的,但因为改变位置要遍历的原因,提交后时间超出;但功能完整#includeusing namespace std;struct link{int number;string begin;string end;link* next;};struct format{string first;int sum;int k; };us
2017-11-12 21:29:40
251
原创 02-线性结构2 一元多项式的乘法与加法运算(20 分)(CPP)
#includeusing namespace std; struct PolyNode{int xishu;int cishu;PolyNode* Next;};using list=PolyNode*;list Read(){int n;cin>>n;list s=(list)malloc(sizeof(PolyNode));list m=s;
2017-11-12 09:25:44
461
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅