![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
考研
简简单单的貔貅
这个作者很懒,什么都没留下…
展开
-
排序(2021.7.22)
考研 ing 努力努力再努力 ** 1.双向冒泡 void bubble(ElemType A[],int n){ int low=0,high=n-1; bool flag=true; while(low<high&&flag){ flag=false; for(i=low;i<high;i++){ if(A[i]>A[i+1]) swap; flag=true; } high--; for(i=high;i>low;i原创 2021-07-22 23:52:19 · 103 阅读 · 0 评论 -
查找(2021.7.21)
考研 ing 努力努力再努力 ** 1.折半查找递归 typedef struct{ elemtype *elem; int length; }SStable; int seare(SStable S,elemtype key,int low,int high){ if(low>high) return 0; mid=(low+high)/2; if(S.elem[mid]>key) seare(S,key,low,mid-1); else if(S.elem[mid]<原创 2021-07-21 23:03:45 · 56 阅读 · 0 评论 -
图(2021.7.19)
考研 努力努力再努力 ** 1.将邻接表转换为邻接矩阵 void convert(ALGraph &G,int arcs[M][N]){ for(i=0;i<n;i++){ p=(G->v[i]).firstarc; while(p){ arcs[i][p->data]=1; p=p->nextarc; } } }原创 2021-07-19 15:41:58 · 124 阅读 · 0 评论 -
二叉排序、二叉平衡、哈夫曼(2021.7.17)
考研 ing 努力努力再努力 ** 1.判断是否为二叉排序树 递归 key pre=-32767 //全局变量,-∞ int judgebst(BiTree t){ int b1,b2; if(t==NULL) return 1; else{ b1=judgebst(t->lchild); if(b1==0||pre>=t->data) return 0; pre=t->data; b2=judgebst(t->rchild); retu原创 2021-07-17 14:59:21 · 42 阅读 · 0 评论 -
树与森林(2021.7.15)
考研 ing 努力努力再努力 ** 1.树的三种存储结构(课本) 1.双亲表示法 typedef struct PNode{ ElemType data; int parent; }PNode; typedef struct{ PNode nodes[maxsize]; int r,n; //根的位置和结点个数 }PTree; 2.孩子表示法 typedef struct CNode{ int child; //孩子链表存储孩子位置 struct CNode *child; }原创 2021-07-15 16:26:07 · 82 阅读 · 0 评论 -
树(2021.7.11晚)
考研 ing 努力努力再努力 ** 第五章 树 1.基础知识 线索二叉树 typedef struct ThreadNode{ ElemType data; struct ThreadNode *lchild,*rchild; int ltag,rtag; }ThreadNode,*ThreadTree; 中序线索二叉树构造(不带头结点) void InThread(ThreadTree &p,ThreadTree &pre){ if(p!=NULL){ InThread(p-原创 2021-07-11 23:48:38 · 110 阅读 · 0 评论 -
栈与队列(2021-07-08晚)
考研 ing 努力努力再努力 ** 第三章 栈与队列 1.循环队列带标志位 入队 int EnQueue(SqQueue &Q,ElemType x){ if(Q.rear==Q.front&&Q.tag==1) return 0; Q.data[Q.rear]=x; Q.rear=(Q.rear+1)%MaxSize; Q.tag=1; return 1; } 出队 int DeQueue(SqQueue &Q,ElemType &x){ if(Q.原创 2021-07-08 23:03:46 · 78 阅读 · 0 评论