摘要: 代码运行截图: 完整代码: #include <stdio.h> #include <stdlib.h> #define MaxSize 20 #define MAX 999 typedef struct ArcNode{ //边表 int adjvex; //边表中是顶点号!! struct Ar 阅读全文
posted @ 2023-12-02 21:02 四马路弗洛伊德 阅读(60) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> void shellSort(int arr[],int n) { int dk,i,j,p; for(dk=n/2;dk>=1;dk=dk/2) { for(i=dk+1;i<n;i++) { if(arr[i]<arr 阅读全文
posted @ 2023-12-02 15:28 四马路弗洛伊德 阅读(33) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ int NO; int Age; char Name[50]; }Student; typedef struct{ int StudentCount; 阅读全文
posted @ 2023-12-02 15:28 四马路弗洛伊德 阅读(50) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ int NO; int Age; char Name[50]; }Student; typedef struct{ int StudentCount; 阅读全文
posted @ 2023-12-02 15:27 四马路弗洛伊德 阅读(34) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #include <string.h> typedef struct{ int NO; int Age; char Name[50]; }Student; typedef struct{ int StudentCount; 阅读全文
posted @ 2023-12-02 15:27 四马路弗洛伊德 阅读(39) 评论(0) 推荐(0)
摘要: 折半是查找函数,是在已排序序列中找到合适的位置让元素插入 首先明确,插入排序算法,是将未排序元素插入到已排序序列中去,重要的始终是已排序序列。 折半查找,就是为了提高在已排序序列中查找最终位置的效率 ACC==1升序,ACC 1降序 #include <stdio.h> #include <stdl 阅读全文
posted @ 2023-12-02 14:25 四马路弗洛伊德 阅读(62) 评论(0) 推荐(0)
摘要: 0 1 2 3 4 5 2 8 12 3 从下标1开始遍历,默认第一个元素是已排序序列。 例如对元素3进行插入排序: 下标0-3分别是2-5-8-12; 此时k=arr[4]=3; j=i-1=3; 从后往前遍历找到k应该插入的位置 当while循环条件 j>=0&&arr[j]>k 一直成立时,a 阅读全文
posted @ 2023-12-02 13:54 四马路弗洛伊德 阅读(42) 评论(0) 推荐(0)
摘要: 两种写法,一个是边表顶点号全部压栈,一个是类似后序非递归遍历 1、 void DFS(Graph G,int i) { int p,w; Stack S; InitStack(S); Push(S,i); visited[i]=true; while(!isEmpty(S)) { Pop(S,p); 阅读全文
posted @ 2023-11-27 22:27 四马路弗洛伊德 阅读(305) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #define MaxSize 20 typedef int VertexType; typedef int EdgeType; typedef int Elem ; typedef struct{ //邻接矩阵 Vert 阅读全文
posted @ 2023-11-26 22:17 四马路弗洛伊德 阅读(60) 评论(0) 推荐(0)
摘要: #include <stdio.h> #include <stdlib.h> #define MaxSize 20 typedef int VertexType; typedef int EdgeType; typedef int Elem ; typedef struct{ //邻接矩阵 Vert 阅读全文
posted @ 2023-11-24 22:26 四马路弗洛伊德 阅读(59) 评论(0) 推荐(0)