摘要: //顶点的度 //邻接表 int count_Degree(Graph G,int v){ int count=0; ENode *p; for(p=adjList[v].firstarc;p!=null;p=p->nextarc){ count++; }//出度 for(int i=0;i<G.v 阅读全文
posted @ 2019-12-26 10:29 ZzUuOo666 阅读(322) 评论(0) 推荐(0) 编辑
摘要: //顺序表中,删除所有元素值为k的元素 O(n) O(1) void Delete(Sqlist &L,int k){ int num=0; int i=0,j=0; while(j<=L->length-1){ if(L->data[j]!=k){ L->data[i++]=L->data[j++ 阅读全文
posted @ 2019-12-26 10:28 ZzUuOo666 阅读(301) 评论(0) 推荐(0) 编辑
摘要: //逆置不带头结点的单循环链表,有尾指针 void invert(LinkList &head){ LNode *p,*a,*r; p=head->next; q=p->next; p->next=head; while(p!=head){ r=q->next; q->next=p; p=q; q= 阅读全文
posted @ 2019-12-26 10:24 ZzUuOo666 阅读(384) 评论(0) 推荐(0) 编辑
摘要: //单链表的直接插入排序 void InsertSort(LinkList &L){ LNode *p=L->next; LNode *q,*r; if(p!=null){//原单链表中有一个或多个结点 r=p->next;//保存p结点的后继结点 p->next=null; p=r; while( 阅读全文
posted @ 2019-12-25 10:55 ZzUuOo666 阅读(676) 评论(0) 推荐(0) 编辑
摘要: //二叉排序树 //从大到小输出>=k的关键字 20 void OutPut(BTNode *t,int k){ if(t==null) return; if(t->rchild!=null){ OutPut(t->rchild,k); } if(t->data>=k){ printf("%d\n" 阅读全文
posted @ 2019-12-25 10:53 ZzUuOo666 阅读(361) 评论(0) 推荐(0) 编辑
摘要: //线索二叉树 //中序遍历线索二叉树 19 //tag为0 指示有孩子 tag为1说明有前驱或后继 BTNode *firstNode(BTNode *t){ while(t->ltag==0){ t=t->lchild; } return t; } BTNode* NextNode(BTNode 阅读全文
posted @ 2019-12-25 10:51 ZzUuOo666 阅读(309) 评论(0) 推荐(0) 编辑
摘要: //先序遍历下的第k个结点 int preorder(BTNode *t,int k,int n){ int result; if(t==null) return 0; if(n==k) return t->data; result=preorder(t->lchild,k,n+1); if(res 阅读全文
posted @ 2019-12-25 10:50 ZzUuOo666 阅读(447) 评论(0) 推荐(0) 编辑
摘要: //删除叶子节点 void Delete_leaf(BTNode *t){ if(t==null) return; if(t->lchild!=null){ BTNode* tlchild=t->lchild; if(tlchild->lchild==null && t->trchild==null 阅读全文
posted @ 2019-12-23 13:05 ZzUuOo666 阅读(2178) 评论(0) 推荐(0) 编辑
摘要: //已知先序和中序建立一颗二叉树 void CreateTree(BTTree t,int[] pre,int[] in, int l1,int h1,int l2,int h2){//l1 为先序数组的第一个,h1 为先序数组的最后一个 int i; T=(BTNode*)malloc(sizeo 阅读全文
posted @ 2019-12-23 13:04 ZzUuOo666 阅读(398) 评论(0) 推荐(0) 编辑
摘要: //同时统计叶子节点数和非叶子节点数 10 void Count(BTNode *t,int &num1,int &num2){ if(t==null) return; else{ if(t->lchild==null && t->rchild==null){ num1++; }else{ num2 阅读全文
posted @ 2019-12-23 13:03 ZzUuOo666 阅读(1044) 评论(0) 推荐(1) 编辑