随笔分类 -  数据结构

摘要:vector V;int N;int a[MAXN];int x;int main () { cin >> N; REP(i,N) { cin >> x; V.push_back(make_pair(x,i)); } sort(V.begin(),V.end()); REP(i,N) a[V[... 阅读全文
posted @ 2015-03-04 18:10 闪光阳 阅读(99) 评论(0) 推荐(0)
摘要:本篇博客会持续跟新。。。。。线段树1.概念 线段树是一种完全二叉树,与区间树相似,它将一个区间划分成一些单元区间,每个单元区间分别对应着线段树中的一个叶节点。主要用于区间的动态查询问题,每次操作的复杂度为O(logn)。2.性质 如果父亲节点表示区间[a,b],那么左儿子表示的区间为[a,(a ... 阅读全文
posted @ 2015-03-04 15:01 闪光阳 阅读(224) 评论(0) 推荐(0)
摘要:head 头指针#include #include #include #include #include #include #include #include #include #include #include #include #include #include #define REP(i,N)... 阅读全文
posted @ 2015-02-24 10:11 闪光阳 阅读(178) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 #define MAXN 1000 8 int low[MAXN],visit[MAXN]; // low[i] = min(visit[i],v... 阅读全文
posted @ 2015-01-03 15:52 闪光阳 阅读(427) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 template class BSTNode{ 9 public: 10 E data; 11 int ... 阅读全文
posted @ 2015-01-01 16:48 闪光阳 阅读(176) 评论(0) 推荐(0)
摘要:1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 class Node { 9 public: 10 int row,col; 11 int value; ... 阅读全文
posted @ 2014-11-23 15:48 闪光阳 阅读(771) 评论(1) 推荐(0)
摘要:在讲三元组之前,让我回忆一下,正常情况下该如何存储一个矩阵呢?话不多说,看下面的代码1 void save_Matrix() {2 int row,col;3 cin >> row >> col;4 for (int i = 0;i > a[i][j];7 }... 阅读全文
posted @ 2014-11-08 12:13 闪光阳 阅读(381) 评论(0) 推荐(0)
摘要:为什么要对next进行改进呢?因为next存在缺陷。。。O(∩_∩)O哈哈~。。。什么缺陷呢?课上老师PPT中的那个例子不太好,并没有把核心体现出来,只是一部分,所以请结合课件和下面的例子仔细体会。设 S串 abcabdabcabcd ;P串 abcabcd好了,先求出P串的next[],(听... 阅读全文
posted @ 2014-11-07 19:33 闪光阳 阅读(3112) 评论(0) 推荐(0)
摘要:在讲KMP之前请允许我回顾一下BF算法,那么什么叫BF算法呢?就是最普通的暴力,请见下方的代码 1 int return_pos(string S,string P) { 2 int i = 0,j = 0,k = 0; 3 int Slen = S.length(); 4 ... 阅读全文
posted @ 2014-11-07 19:32 闪光阳 阅读(524) 评论(1) 推荐(0)