
数据结构
ERROR无限
这个作者很懒,什么都没留下…
展开
-
broken keyboards
You're typing a long text with a broken keyboard. Well it's not so badly broken. The only problemwith the keyboard is that sometimes the \home" key or the \end" key gets automatically pressed(inte原创 2016-02-10 11:44:08 · 730 阅读 · 0 评论 -
邻接表实现prim
///*******linjiebiao*************************#include#include#includeusing namespace std;const int inf = 65535;typedef struct arcnode{///存边 int adjvex; int weight; arcnode *nextarc;原创 2016-11-16 20:44:23 · 1852 阅读 · 0 评论 -
先序 中序 后序 线索二叉树
///有头结点版 + 无头结点版 啊啊啊啊啊啊 感觉自己快吐血了 T^T#include#includeusing namespace std;typedef struct treenode{ char data; treenode *lchild; treenode *rchild; int LTag; int RTag;}node, *原创 2016-11-13 20:44:03 · 849 阅读 · 0 评论 -
最小生成树 prim算法
学了也有一段时间了,可是我现在才去总结, 该打!!!(PS: 我怎么变得这么暴力了)/*#include using namespace std;void prim(){ const int INF = 65536;//表示无穷大 const int N = 100;//N为图中所有的节点数 bool visited[N+1] = {false};//数组vi原创 2016-05-19 12:16:14 · 285 阅读 · 0 评论 -
三叉链表实现二叉树基本操作
#include#include#includeusing namespace std;int head, tail;typedef struct treenode{ char data; treenode *lchild; treenode *rchild; treenode *parent;}node, *Tree;node *q[100];原创 2016-11-15 21:01:45 · 2863 阅读 · 0 评论 -
Adjacency List Dijkstra
///啊 次我一个太滚吧~#include#includeusing namespace std;struct arcnode{ int adjvex; int weight; arcnode *nextarc;};typedef struct vnode{ int data; arcnode * firstarc;}Adjvex[20];原创 2016-12-02 20:58:50 · 366 阅读 · 0 评论 -
链栈 链队列 share
发现自己好像越来越low了 没四儿 开心就好///链栈#include using namespace std;typedef struct node///几种不同的打包方式 自己总是糊里糊涂的 多看看吧{ int data; node *next; node *top;}LinkStack;//typedef struct{ node *原创 2016-11-22 19:05:10 · 308 阅读 · 0 评论 -
图toposort
///有向无环图///拓扑排序///图的各种表示法 汇总///1.邻接矩阵/*#include #include #includeusing namespace std;int deg[100];bool vis[100];int map1[100][100];int a[100];void toposort(int n){ priority_queue ,原创 2016-12-04 15:48:41 · 480 阅读 · 0 评论 -
图
/*#include #includeusing namespace std;typedef struct arcnode{ int weight; int adjvex; arcnode *nextarc;}arcnode;typedef struct vnode{ int data; arcnode *firstarc;}Adjvex原创 2016-11-25 21:15:59 · 263 阅读 · 0 评论 -
binary search tree
///之前写的在删节点时 都没有维持二叉排序树的形态 所以重写一遍 还挺好玩的#includeusing namespace std;typedef struct treenode{ int data; treenode *lchild; treenode *rchild;}node, *Tree;int head, tail;node *q[100];in原创 2016-12-08 18:22:31 · 249 阅读 · 0 评论 -
AVLtree
/*******************************author: yomidate: 17.1.13mood:짱짱짱ps:기뿐이 너무 촣다~*******************************////这个是按照深度 判断平衡程度 也可以直接定义一个平衡程度变量#include#include #include using namespace std;原创 2017-01-14 10:43:35 · 233 阅读 · 0 评论 -
堆的创建 插入和删除
바빠 바빠 바빠~///heap#includeusing namespace std;void heap_insert(int *heap, int i, int num){ int j = (i-1)>>1; heap[i] = num; while(j>=0 && i!=0){ if(heap[j] < num) br原创 2017-01-14 15:04:29 · 264 阅读 · 0 评论 -
AVL tree 调整方法
平衡二叉树对于二叉查找树,尽管查找、插入及删除操作的平均运行时间为O(logn),但是它们的最差运行时间都是O(n),原因在于对树的形状没有限制。平衡二叉树又称为AVL树,它或者是一棵空树,或者是有下列性质的二叉树:它的左子树和右子树都是平衡二叉树,且左右子树的深度之差的绝对值不超过1。二叉树的的平衡因子BF为:该结点的左子树的深度减去它的右子树的深度,则平衡二叉树的所转载 2017-01-12 14:22:49 · 581 阅读 · 0 评论 -
二叉搜索树的创建 查找 删除
///此处省去概念若干字~ 欢迎指错#include #includeusing namespace std;typedef struct treenode{ int data; treenode *lchild; treenode *rchild;}node;int flag = -1;void insert_node(node* root, node*原创 2016-11-01 15:22:39 · 444 阅读 · 1 评论 -
哈希表
算不上详解 只有散列函数的介绍 还有我用了一整节数据结构再加一个多小时调出来的代码/*好的散列函数要求:(1)计算简单,至少散列函数的计算时间不应该超过其他查找技术与关键字比较的时间;(2)计算出的散列地址分布均匀,这样可以保证存储空间的有效利用,并减少为处理冲突而耗费的时间。1. 直接定址法取关键字或关键字的某个线性函数值为散列地址。即H(key)=key或H(key) = a原创 2016-10-18 21:52:35 · 376 阅读 · 2 评论 -
基数排序
第一步以LSD为例,假设原来有一串数值如下所示:73, 22, 93, 43, 55, 14, 28, 65, 39, 81首先根据个位数的数值,在走访数值时将它们分配至编号0到9的桶子中:01 812 223 73 93 434 145 55 65678 289 39第二步接下来将这些桶子中的数值重新串接起来,成为以下的数列:81,原创 2016-04-03 20:24:40 · 229 阅读 · 0 评论 -
线段树的创建
在一天马上要结束的时候 赶紧发博客~~#include using namespace std;const int maxind = 256;int segTree[maxind * 4 + 10];int array[maxind];/* 构造函数,得到线段树 */void build(int node, int begin, int end){ if (begin ==原创 2016-04-05 22:52:38 · 274 阅读 · 0 评论 -
树状数组
lowbit就是2^k.而c[x]就是i-2^k+1 ~ i#includeusing namespace std;const int maxn = 2000;int a[maxn];int c[maxn];int getsumval(int x){ int sum = 0; while(x>0) { sum += c[x];原创 2016-04-12 15:59:33 · 194 阅读 · 0 评论 -
线段树
#include #include #include #include #include #include #include #include #include #include #include #include #define inf 0x0f0f0f0fusing namespace std;const int N=200010;const int M=50原创 2016-04-12 16:16:37 · 213 阅读 · 0 评论 -
返回十进制转换成二进制数的第i位
#include using namespace std;typedef unsigned long long ull;ull bits(ull x,int i){ return (x >> i) & 1ULL;}int main(){ int testCase,i; while (cin>>testCase>>i) { cout<<原创 2016-05-14 20:32:42 · 337 阅读 · 0 评论 -
最小生成树 Kruskal算法
Kruskal算法是基于贪心的思想得到的。首先我们把所有的边按照权值先从小到大排列,接着按照顺序选取每条边,如果这条边的两个端点不属于同一集合,那么就将它们合并,直到所有的点都属于同一个集合为止。这里需要用到并查集。换而言之,Kruskal算法就是基于并查集的贪心算法。HDU1863是个很好的例子。 我们用现在来模拟一下Kruskal算法,下面给出一个无向图B,我们使用K原创 2016-05-23 20:40:35 · 365 阅读 · 0 评论 -
判断两个单链表是否相交 输出入口点
额 做这题用了我大半节实验课再加将近一个小时 样例过了 如果有错误 就麻烦路过的大牛指出来 额 很简单的思想到我这可能就。。。 我先做了两个链表 然后再做个交点出来 然后再判断再把L1放在L2后面, 形成一个环, 再找一下入口点就可以了加注释的是我测试的时候写的 忽略就行PS: 防弹这次歌真好听 jimin jimin jimin 下面上代码 /// first cre原创 2016-10-11 20:42:20 · 319 阅读 · 0 评论 -
稀疏矩阵的压缩存储与快速转置 三元组法 类与对象实现
贴个主函数 这酸爽~#include "TSMatrix.h"#include"Triple.cpp"#include"TSMatrix.cpp"void transMatrix(TSMatrix a,TSMatrix &b);///求三元组顺序表方式,转置矩阵简单的方法,将稀疏矩阵a转置为bvoid quickTransMatrix(TSMatrix a,TSMatrix &b);/原创 2016-10-22 15:00:05 · 1258 阅读 · 0 评论 -
循环链表实现约瑟夫环
数据结构老师在课上提到的 故事背景很有意思 所以我就做了一下/*#includeusing namespace std;/// 第一个不对 暂时还没弄明白typedef struct node{ int data; node *next;/// struct}node;node *createlist(int n){ if(n<1){ co原创 2016-09-26 20:16:17 · 213 阅读 · 0 评论 -
反转单链表
///题不难 思路也很容易理清 只是在实现的过程中老走歪路 唉 我智障 /*#include using namespace std;struct node{ node *next; int data;};int main(){ node *L1, *L2; L1 = new node; L1->next = NULL; L2 =原创 2016-10-25 20:06:16 · 256 阅读 · 0 评论 -
哈夫曼树
///本想着复习一下 二叉树就学哈夫曼的 呵呵哒 复习就用了一晚上 这效率也是没谁了///都粘上。。。/*#include#includeusing namespace std;const int maxn = 100;int n = 0, m = 0;typedef struct treenode{ char data; treenode *lchild;原创 2016-11-10 20:26:46 · 402 阅读 · 0 评论 -
二叉树的基本操作 (二叉链表实现)
///以下代码都是自己根据理解写的 可能有不对的地方 麻烦路过的大神指出来 感激不尽///以下所有操作均只能对第一个值为X的节点进行操作 至于怎么解决这个问题。。。我再想想#include#includeusing namespace std;typedef struct treenode{ char data; treenode *lchild; treenod原创 2016-10-30 23:02:58 · 941 阅读 · 0 评论 -
哈希表 除数余留 + 链地址 && 线性探测 && 平方探测
/*****************************author: yomidate: 17.1.17mood: ps: *******************************//***#includeusing namespace std;const int maxn = 13;struct hash_node{ int data; hash原创 2017-01-17 21:02:24 · 304 阅读 · 0 评论