经典数据结构
winycg
问题可联系QQ:1241981936
展开
-
第K大的数
求第K大数原创 2022-08-18 17:06:37 · 155 阅读 · 0 评论 -
hdu2120 并查集
并查集的作用:1.求联通分量的个数2.判断图中是否有环ice_cream's world is a rich country, it has many fertile lands. Today, the queen of ice_cream wants award land to diligent ACMers. So there are some watchtow原创 2016-03-14 23:26:40 · 449 阅读 · 0 评论 -
poj 1182 经典并查集
Description动物王国中有三类动物A,B,C,这三类动物的食物链构成了有趣的环形。A吃B, B吃C,C吃A。 现有N个动物,以1-N编号。每个动物都是A,B,C中的一种,但是我们并不知道它到底是哪一种。 有人用两种说法对这N个动物所构成的食物链关系进行描述: 第一种说法是"1 X Y",表示X和Y是同类。 第二种说法是"2 X Y",表示X吃Y。 此人对N个动物,用原创 2016-07-29 17:22:27 · 323 阅读 · 0 评论 -
hdu 5441 并查集的应用
DescriptionJack likes to travel around the world, but he doesn’t like to wait. Now, he is traveling in the Undirected Kingdom. There are $n$ cities and $m$ bidirectional roads connecting the citie原创 2016-08-11 09:37:41 · 447 阅读 · 0 评论 -
hdu 1007 分治法求最小点之间的距离(使用分治法模板)
Problem DescriptionHave you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.In the field of Cyberground, the转载 2016-08-12 20:35:43 · 717 阅读 · 0 评论 -
poj 1703 并查集解决分组问题
DescriptionThe police office in Tadu City decides to say ends to the chaos, as launch actions to root up the TWO gangs in the city, Gang Dragon and Gang Snake. However, the police first needs to ide原创 2017-03-09 15:35:55 · 507 阅读 · 0 评论 -
链表问题
#include#include#include#includeusing namespace std;struct LNode{ int data; LNode* next;};void CreatLinkList(LNode* &L){ int n; cin>>n; L=(LNode*)malloc(sizeof(LNode));原创 2017-05-23 22:03:04 · 493 阅读 · 0 评论 -
二叉排序树
二叉搜索树(二叉排序树):(1)是棵空树(2)若左子树不空,左子树上所有结点的值均小于他的根节点的值;若右子树不空,则右子树上所有的结点的值均大于它的根节点的值。(3)左子树和右子树均为二叉排序树#include#include#include#include#include#define inf 0x3f3f3f3fusing namespace std;s原创 2017-05-31 21:46:05 · 264 阅读 · 0 评论 -
Huffman树
#include#include#include#include#include#define inf 0x3f3f3f3fusing namespace std;struct HTNode{ int w; int parent,lchild,rchild;}h[110];int hCode[110][1010];int n;void selectMin(i原创 2017-05-30 11:02:35 · 229 阅读 · 0 评论 -
归并排序
#includeusing namespace std;int a[1010];void merge(int l,int mid,int r)//对区间进行合并排序{ int i=l,j=mid+1,k=0; int c[1010]; while(i<=mid&&j<=r) { if(a[i]<a[j]) c[k++]原创 2017-04-05 11:05:19 · 329 阅读 · 0 评论 -
堆排序
#includeusing namespace std;int h[1010];int n;void HeapAdjust(int s,int m){ for(int i=2*s;i<=m;i=i*2)//左结点序号<=m才有下一层 { if(i<m&&h[i+1]<h[i])//i<m才有右节点 i++; if(h原创 2017-05-22 22:55:26 · 474 阅读 · 0 评论 -
快速排序代码
快速排序#include#include#include#include#include#include#include#include#define inf 0x3f3f3f3f#define ll long longusing namespace std;int a[10]={4,2,6,1,3,5,3};void quicksort(int l,int r){原创 2017-03-26 16:50:01 · 386 阅读 · 0 评论 -
算法复杂度
O(1)在1~5s内可以执行的变量大小lgnnnlgnn^2n^32^n>10^910^910^810^410^330原创 2017-03-10 00:06:44 · 526 阅读 · 0 评论 -
插入排序
#include#include#include#include#include#include#include#include#define inf 0x3f3f3f3f#define ll long longusing namespace std;int a[1010];int n;void InsertSort(){ for(int i=2;i<=n;i+原创 2017-04-06 20:04:13 · 232 阅读 · 0 评论