
数据结构
wwwlps
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
静态链表系列操作
静态链表#include #include using namespace std; #define maxn 105 typedef struct { int data; int cur; }stackLinkList; void init(stackLinkList *L) { for(int i=0;i<maxn-1;i++) L[i].cur=i+1;原创 2017-09-20 20:24:06 · 255 阅读 · 0 评论 -
L2-004 这是二叉搜索树吗?
https://pintia.cn/problem-sets/994805046380707840/problems/994805070971912192 本题目是一道涉及二叉搜索树、树的遍历的裸题,模拟即可,可以建树,也可不建。 贴个代码: #include <iostream> #include <cmath> #include <cstring> ...原创 2019-03-27 10:25:32 · 143 阅读 · 0 评论 -
小根堆(模板)
#include<bits/stdc++.h> using namespace std; const int maxn=55; int n,a[maxn],heap[maxn]; void siftup(int i)//建立小根堆 { int flag=0; if(i==1) return ; while(i!=1&&flag=...原创 2019-03-22 10:42:33 · 693 阅读 · 0 评论 -
trie树 (模板)
#include<bits/stdc++.h> #define LL long long using namespace std; const int maxn=100005; const int maxz=500005; int nex[maxn]; string s; int trie[maxn][26]; int cnt; int endv[maxn]; void build...原创 2019-03-20 11:18:38 · 110 阅读 · 0 评论 -
哈夫曼树(模板)
4198: [Noi2015]荷马史诗 Time Limit:10 SecMemory Limit:512 MB Submit:2269Solved:1216 [Submit][Status][Discuss] Description 追逐影子的人,自己就是影子。 ——荷马 Allison 最近迷上了文学。她喜欢在一个慵懒的午后,细细地品上一杯卡布奇诺,静静地阅读她爱不释手...原创 2019-03-20 10:32:56 · 396 阅读 · 0 评论 -
堆的创建(自顶向下插入)
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> #include<cmath> #include<set> #include<queue> #include<map> #include&a原创 2018-03-04 21:30:11 · 1658 阅读 · 0 评论 -
二叉树 前序+中序->恢复二叉树后序
#include #include typedef struct k { int data; struct k *lc,*rc; }Btree; void inputin(int in[],int n) { int i; for(i=0;i<n;i++) scanf("%d",&in[i]); } void inputpost(int pos[]原创 2017-11-21 11:30:18 · 199 阅读 · 0 评论 -
二叉树 中序+后序->还原二叉树
#include #include typedef struct k { int data; struct k *lc,*rc; }Btree; void inputin(int in[],int n) { int i; for(i=0;i<n;i++) scanf("%d",&in[i]); } void inputpost(int post[原创 2017-11-21 11:13:18 · 223 阅读 · 0 评论 -
快速排序
#include #include #define maxn 1005 using namespace std; int a[maxn]; int n; void quiksort(int l,int r) { int i,j,t; i=l; j=r; if(l>r) { return ; } while(i!=j) {原创 2017-11-04 23:48:29 · 153 阅读 · 0 评论 -
队列操作
队列 #include #include #define maxn 5 using namespace std; typedef struct { int data[maxn]; int head,tail; }Squeue; void init(Squeue *q) { q->head=q->tail=0; } void inSqueue(Squeue *q,int e)原创 2017-10-17 15:37:58 · 485 阅读 · 0 评论 -
单链表及系列操作
#include #include using namespace std; typedef struct Node { int data; struct Node *next; }Node, *LinkList; void input1(LinkList *head) { LinkList p,r; int x; cin>>x;原创 2017-09-19 21:53:05 · 411 阅读 · 0 评论 -
栈stack
简单的栈 typedef struct { int data[maxn]; int top; }SqStack; void initstack(SqStack *S) { S->top=-1; return ; } void inputpush(SqStack *S) { int x; cin>>x; if(S->top==maxn-1) r原创 2017-09-25 16:34:07 · 250 阅读 · 0 评论 -
顺序表及系列操作
顺序表#include #include using namespace std; typedef struct { int data[1005]; int length; }SqList; void input(SqList *p) { int x; cin>>x; int i=0; p->length=0; while(x!=-1)原创 2017-09-20 20:15:30 · 233 阅读 · 0 评论 -
PTA L3-002 特殊堆栈(模拟,vector,stack)
题目:https://pintia.cn/problem-sets/994805046380707840/problems/994805053695574016 题解:模拟即可,保证每次插入使得数组有序,每次弹出也要使得数组有序,每次PeekMedian,直接输出数组中间值即可,但是用普通的数组模拟前两个操作会超时的,这里我们使用vector保存数据(链式结构比较好维护),并用lower_bou...原创 2019-03-29 11:10:51 · 674 阅读 · 1 评论