随笔分类 - 数据结构
转: 单调队列
摘要:我们从最简单的问题开始: 给定一个长度为N的整数数列a(i),i=0,1,...,N-1和窗长度k. 要求: f(i) = max{a(i-k+1),a(i-k+2),..., a(i)},i = 0,1,...,N-1 问题的另一种描述就是用一个长度为k的窗在整数数列上移动,求窗里面所包含的数的最
阅读全文
poj2104--K-th Number(划分树 求区间K小值)
摘要:K-th Number Description Input Output Sample Input Sample Output Hint Source
阅读全文
Poj 2001--Shortest Prefixes(字典树)
摘要:Description Input Output Sample Input Sample Output Source 首次认识到Trie树的强大之处!简单易懂,只要对建立一般的树的方法有所了解就OK了。Trie树,又称单词查找树或键树,是一种树形结构,是一种哈希树的变种。典型应用是用于统计和排序大量
阅读全文
栈、队列
摘要:写了点儿代码, 感觉指针真的不会双栈共享空间:#include #include #include #include const int Maxesize = 101;typedef struct{ int data[Maxesize]; int top1; int top2;}S...
阅读全文
单链表
摘要:注意头插法和尾插法区别;头指针指向链表中第一个结点(头结点也是第一个结点);#include #include #include #include typedef struct Mnode{ int data; struct Mnode *next;}Node, *Linklist;vo...
阅读全文
KMP
摘要:克努特-莫里斯-普拉特(KMP)算法;#include #include const int N = 101;const int M = 51;char a[N], b[M];int lena, lenb, next[M], nextval[M];void Get_next() { in...
阅读全文
排序
摘要:#include #include const int MAXN = 600;int n, num[MAXN];void ShellInsert(int *num, int dk){ int i, j; for(i = dk + 1; i 0 && num[0] = num[j]) ...
阅读全文
表达式求值
摘要:中缀转后缀, 主要是模拟过程吧。1、 建立一个符号栈(存储运算符和括号);2、 表达式中遇到'('入栈;3、 遇到')'将栈中所有元素出栈即括号和括号内所包含的运算符;4、 数字字符直接存到数组中;5、根据运算符优先级来入栈和出栈运算符, 即当前运算符优先级大于栈顶元素优先级直接入栈, 小于的话出栈...
阅读全文
数据结构之顺序表
摘要:已知Sqlist 是一个结构体变量, 其中包含data这类整形元素, 定义一个 Sqlist *L. L->data = (* L).data.#include #include #define OK 1#define ERROR 0#define MAXSIZE 20typedef int Sta...
阅读全文
浙公网安备 33010602011771号