摘要:
#ifndef _HASHTABLE_H_ #define _HASHTABLE_H_ #include <iostream> #include <cstdlib> using namespace std; typedef enum { Empty, Active, Deleted }kindofitem; typedef struct { int key; }datatype; typedef 阅读全文
posted @ 2019-10-23 19:06
bestAndBest
阅读(2788)
评论(0)
推荐(0)
摘要:
算法思想:1.将长度为n的待排序的数组进行堆有序化构造成一个大顶堆 2.将根节点与尾节点交换并输出此时的尾节点 3.将剩余的n -1个节点重新进行堆有序化 4.重复步骤2,步骤3直至构造成一个有序序列 代码: 阅读全文
posted @ 2019-10-23 16:55
bestAndBest
阅读(1310)
评论(0)
推荐(0)
摘要:
归并操作的工作原理如下: 第一步:申请空间,使其大小为两个已经排序序列之和,该空间用来存放合并后的序列 第二步:设定两个指针,最初位置分别为两个已经排序序列的起始位置 第三步:比较两个指针所指向的元素,选择相对小的元素放入到合并空间,并移动指针到下一位置 重复步骤3直到某一指针超出序列尾 将另一序列 阅读全文
posted @ 2019-10-23 16:20
bestAndBest
阅读(863)
评论(0)
推荐(0)
摘要:
void shellSort(int arr[], int n) { int h = 1; while (h = h && e < arr[j - h]; j - h) { arr[j] = arr[j - h]; } arr[j] = e; } ... 阅读全文
posted @ 2019-10-23 12:26
bestAndBest
阅读(128)
评论(0)
推荐(0)
摘要:
#include #include #include using namespace std; const int M=500; int cost[M][M]; int Creat(){ int n,m; cin>>n>>m; for(int q=1;q>a>>b>>c; cost[a][b]=c; cost[b][a]=c; } ... 阅读全文
posted @ 2019-10-23 12:18
bestAndBest
阅读(347)
评论(0)
推荐(0)
摘要:
/* * 克鲁斯卡尔(Kruskal)最小生成树 */ void kruskal(Graph G) { int i,m,n,p1,p2; int length; int index = 0; // rets数组的索引 int vends[MAX]={0}; // 用于保存"已有最小生成树"中每个顶点在该最小树中的终点。 EDa... 阅读全文
posted @ 2019-10-23 12:17
bestAndBest
阅读(496)
评论(0)
推荐(0)
摘要:
核心思想:从i号顶点到j号顶点只经过前k号点的最短路程 阅读全文
posted @ 2019-10-23 12:10
bestAndBest
阅读(670)
评论(0)
推荐(0)
摘要:
#include #include #include using namespace std; const int maxn = 100; int map[maxn][maxn]; int dis[maxn]; int path[maxn]; int vis[maxn]; int n; void DIJ(int s) { memset(path, -1, sizeof(path)); ... 阅读全文
posted @ 2019-10-23 12:05
bestAndBest
阅读(252)
评论(0)
推荐(0)

浙公网安备 33010602011771号