
经典数据结构
winycg
问题可联系QQ:1241981936
展开
-
第K大的数
求第K大数原创 2022-08-18 17:06:37 · 205 阅读 · 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 · 473 阅读 · 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 · 345 阅读 · 0 评论 -
hdu 5441 并查集的应用
Description Jack 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 · 478 阅读 · 0 评论 -
hdu 1007 分治法求最小点之间的距离(使用分治法模板)
Problem Description Have 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 · 747 阅读 · 0 评论 -
poj 1703 并查集解决分组问题
Description The 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 · 540 阅读 · 0 评论 -
链表问题
#include #include #include #include using 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 · 516 阅读 · 0 评论 -
二叉排序树
二叉搜索树(二叉排序树): (1)是棵空树 (2)若左子树不空,左子树上所有结点的值均小于他的根节点的值;若右子树不空,则右子树上所有的结点的值均大于它的根节点的值。 (3)左子树和右子树均为二叉排序树 #include #include #include #include #include #define inf 0x3f3f3f3f using namespace std; s原创 2017-05-31 21:46:05 · 284 阅读 · 0 评论 -
Huffman树
#include #include #include #include #include #define inf 0x3f3f3f3f using 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 · 249 阅读 · 0 评论 -
归并排序
#include using 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 · 355 阅读 · 0 评论 -
堆排序
#include using 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 · 498 阅读 · 0 评论 -
快速排序代码
快速排序 #include #include #include #include #include #include #include #include #define inf 0x3f3f3f3f #define ll long long using namespace std; int a[10]={4,2,6,1,3,5,3}; void quicksort(int l,int r) {原创 2017-03-26 16:50:01 · 408 阅读 · 0 评论 -
算法复杂度
O(1) 在1~5s内可以执行的变量大小 lgn n nlgn n^2 n^3 2^n >10^9 10^9 10^8 10^4 10^3 30原创 2017-03-10 00:06:44 · 551 阅读 · 0 评论 -
插入排序
#include #include #include #include #include #include #include #include #define inf 0x3f3f3f3f #define ll long long using namespace std; int a[1010]; int n; void InsertSort() { for(int i=2;i<=n;i+原创 2017-04-06 20:04:13 · 260 阅读 · 0 评论