
考研
简简单单的貔貅
这个作者很懒,什么都没留下…
展开
-
排序(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 · 136 阅读 · 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 · 84 阅读 · 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 · 175 阅读 · 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 · 69 阅读 · 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 · 127 阅读 · 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 · 143 阅读 · 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 · 98 阅读 · 0 评论