自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(15)
  • 收藏
  • 关注

原创 算法导论第十三章 红黑树

文章目录红黑树的定义旋转插入删除习题集合思考题 红黑树的定义 旋转 左旋伪代码 LEFT-ROTATE(T,x) 1. y = x.right // 说明x的右孩子为y 2. x.right = y.left // y的左孩子 设为 x的右孩子,即 将β设为x的右孩子 3. if y.left != T.null 4. y.left.p = x 5. y.p = x.p // x的父...

2019-08-11 16:32:46 329

原创 算法导论 第十二章 二叉

二叉搜索树定义: 对于任何结点x,其左子树中的关键字最大不超过x.key,其右子树中的关键字最小不小于x.key。而这个性质队树中的每个结点都成立。 遍历 算法部分:有递归版本有非递归版本 分为先序,中序,后序 INORDER-TREE-WALK( x ) 1. if x ≠NULL 2. INORDER-TREE-WALK(x ->x.lelf) 3. print x....

2019-08-08 09:01:43 213

原创 算法导论第7,8章快排及线性时间排序

先是第八章 线性时间排序 排序算法的下界 最坏情况的下界: 定理一:在最坏的情况下,任何比较排序算法都需要做下界 为nlgn次比较 定理二:堆排序和归并排序都是渐近最优的比较排序算法 练习: 8.1-1 最少进行n-1次比较,所以深度最小是n-1 8.1-2 斯特林近似公式 8.1-3 key在于n!<=l<=2^h 8.1-4 计数排序 基数排序 桶排序 ...

2019-07-28 10:57:38 163

原创 算法导论-第六章堆排序

假设在第i 次迭代之前,循环不变式为真。那么此时子数组A[1..i] 包含了整个数组A[1..n] 中最小的i个元素,并且A[1..i]是一个最大堆,因此A[1] 保存了子数组A[1..i]中的最大元素,也就是整个数组A[1..n] 中第n−i+1大的元素(有n−i 个元素比它大,所以按从大到小顺序,它是第

2019-07-23 20:26:49 274

原创 ds

#include&lt;bits/stdc++.h&gt; struct a{ int data; struct a*next; }; struct a*creakline() { struct a*H; H=(struct a*)malloc(sizeof(struct a)); H-&gt;next=NULL; return H; } void insert(struct a*l)...

2018-12-27 09:26:22 317

转载 反对

#include&lt;iostream&gt; #include&lt;cstring&gt; #include&lt;cstdlib&gt; #define maxn 1000 using namespace std; int a[maxn], b[maxn]; bool myStrcmp(const char str1[], const char str2[]) { if(strl...

2018-12-27 08:45:43 132

翻译 连通图的DFS,BFS,并查集的试探

自己的DFS,样例没过,果然还是菜 #include &amp;lt;iostream&amp;gt; #include&amp;lt;cstdio&amp;gt; #define n 100 using namespace std; int v,s; //int flag[n]; int DFS(int G[][n],int s ) { int count = 0; int vis[n] = { 0 }; vis[s...

2018-12-14 00:58:29 203

原创 图,dfs,bfs

真的大一菜鸟的dfs dfs: void dfs(int st,int g[][max])//必须给一个顶点开始搜索 { static int vis[max]={0}; //用于记录有没有被访问 vis[st]=1; //开始找说有项链的节点中没有被访问过的节点 printf("%2d-&gt;",...

2018-12-12 09:28:46 268

原创 链表学习

突然讲链表,哼 #include&lt;stdio.h&gt; #include&lt;stdlib.h&gt; //定义个链表。 struct NODE{ int order; char name[20]; struct NODE *pnext;//指向truct node的一个指针,链的产生这 }; //创建节点...

2018-12-12 09:02:55 321 1

原创 HDOJ2011多项式求和

不能AC #include &lt;iostream&gt; #include&lt;cstdio&gt; using namespace std; int main() { int n,flag; while(scanf("%d",&amp;n)!=EOF) { while(n) { flag=1; ...

2018-12-08 22:54:04 157

原创 HDOJ2009

#include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cmath&gt; using namespace std; int main () { int m; double sum=0,n; while(scanf("%lf%d",&amp;n,&amp;m)!=EOF) { sum=n...

2018-12-07 23:00:56 81

原创 HDOJ2008数值统计

#include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cmath&gt; using namespace std; int main () { int z,f,zero,n; while(scanf("%d",&amp;n)!=EOF) { if(n==0)break; z=0...

2018-12-07 21:44:09 251

原创 HDOJ2006平方和与立方和

#include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cmath&gt; using namespace std; int main () { int a,b,t,ou=0,ji=0; while(scanf("%d%d",&amp;a,&amp;b)!=EOF) { ou=0; ...

2018-12-07 21:34:52 275 1

原创 HD2006 求奇数的乘积

#include #include using namespace std; int main () { int str=1,n; while(scanf("%d",&amp;n)!=EOF) { str=1; for(int i=0;i&lt;n;i++) { int s; cin&gt;&gt;s; if(s%2!=0) str*=s; else continue; } cout&lt;&lt...

2018-12-07 21:24:05 116

原创 HD2003求绝对值

#include #include #include using namespace std; int main () { double r; while(cin&gt;&gt;r) { printf("%.2lf\n",fabs(r)); } }

2018-12-07 20:31:38 182

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除