数据结构
Pioneer_0619
我很懒,还没有添加简介呢。
展开
-
【数据结构】
人最难做到的就是坚持,即使是期末周我也要坚持每天打卡看完一个视频并完成一个程序的代码。加油!#include<iostream>using namespace std;void bubbleSort(int r[], int n) { int bound = 0, exchange = n - 1; while (exchange) { bound = exchange; //bound为无序区的右边界 exchange = 0; for (int j = 0; j原创 2021-12-13 07:48:26 · 266 阅读 · 0 评论 -
【数据结构】插入排序之希尔排序
#include<iostream>using namespace std;void shellSort(int r[], int n) { for (int d = n / 2; d >= 1; d = d / 2) { for (int i = d + 1; i <= n; i++) { r[0] = r[i]; int j = i - d; while (j > 0 && r[0] < r[j]) { r[j...原创 2021-12-12 08:14:02 · 601 阅读 · 0 评论 -
※【数据结构】平衡二叉树
原创 2021-12-09 07:46:47 · 364 阅读 · 0 评论 -
※【数据结构】二叉排序树
为什么public的方法还要去调用private的方法呢?它们的功能实现不都是一样的吗?为什么不能直接定义成public呢?为了保证封闭性,有些函数如果直接暴露给外界可能比较危险,但是如果通过public间接调用,虽然功能一样,但是后期利于维护,如果这个功能我不想让外界用,直接把public里的方法修改就行了,不用去动private方法,private都比较重要,避免后期修改private产生错误...原创 2021-12-07 07:52:34 · 361 阅读 · 0 评论 -
【数据结构】AOE网与关键路径
快速求解方法:数据结构—图,一分钟求解关键路径!原创 2021-12-04 08:27:54 · 463 阅读 · 0 评论 -
【数据结构】AOV网与拓扑排序
typedef struct ArcNode{ //边结点 int adjvex; //顶点下标 ArcNode *next;}ArcNode;typedef struct{ int in; //in是入度 string vertex; //顶点信息 ArcNode *firstEdge; }vertexNod...原创 2021-12-02 21:21:10 · 1171 阅读 · 0 评论 -
※【数据结构】娱乐选址问题
有n个地点编号1~n,在其中一个地点建立娱乐中心,要求该点距其它各地点的最长往返路程最短,相同条件下总的往返路程和越短越好,如果仍相同,取编号最小的地点,问娱乐中心应选址何处?娱乐选址问题...原创 2021-12-01 18:42:52 · 824 阅读 · 0 评论 -
【数据结构】最短路径Floyd
加油!原创 2021-12-01 08:08:17 · 514 阅读 · 0 评论 -
【数据结构】最短路径(Dijsktra算法)
最小生成树与最短路径的区别最短路径问题最短路径是求两点之间路径最短的问题,应用如导航,两个地方怎么走距离最短。可以存在到不了的情况。这个问题是说,如何找到从某个特定的节点出发,通向其他节点的最短路径。它只着眼于点与点之间的路径问题,并不关注整个图,也就意味着对一个节点运行算法的结果与另一个节点的结果之间没有多少关系。比如说,可以把城市的路口看作图的节点,把公路看做边,综合长度、拥堵程度等指标作为边的权重,就可以通过Dijkstra算法计算出从城市一点到另一点的最短路线。最小生成树问题最小生成树.原创 2021-11-30 09:06:52 · 982 阅读 · 0 评论 -
【数据结构】Kruskal算法最小生成树
#include<iostream>#define dataType intusing namespace std;const int MaxVertex = 10;const int MaxEdge = 100;struct EdgeType { int from, to; int weight;};class EdgeGraph { private: dataType vertex[MaxVertex]; EdgeType edge[MaxVertex];...原创 2021-11-29 21:03:44 · 170 阅读 · 0 评论 -
【C】折半查找二分查找
#include<iostream>using namespace std;void insertSort(int r[],int n){ int temp; for(int i=1;i<n;i++){ temp = r[i]; int j = i-1; while(temp<r[j]&&j>=0){ r[j+1] = r[j]; j--; } r[j+1] = temp; }}void binarySea..原创 2021-11-29 09:36:44 · 175 阅读 · 0 评论 -
【数据结构】插入排序之直接插入排序与折半二分排序
#include<iostream>using namespace std;void insertSort(int r[],int n){ for(int i=2;i<=n;i++){ r[0] = r[i]; int j = i-1; while(r[0]<r[j]&&j>=1){ r[j+1] = r[j]; j--; } r[j+1] = r[0]; }}int main(){ int array[6].原创 2021-11-29 07:50:54 · 369 阅读 · 0 评论 -
【数据结构】prim算法最小生成树
作业原创 2021-11-24 21:11:22 · 471 阅读 · 0 评论 -
【数据结构】广度优先遍历 最小转机问题
题目描述:小哼和小哈一同坐飞机去旅游,他们现在位于1号城市,目标是5号城市,可是1号城市并没有到5号城市的直航。不过小哼已经收集了很多航班的信息,现在小哼希望找到一种乘坐方式,使得转机的次数最少,如何解决?输入:第一行输入n,m,n表示城市的数量,m表示城市间的的航线,城市编号从1-n。接下来m行输入每两个城市间的航线最后一行输入起点城市和终点城市样例:5 71 21 32 32 43 43 54 51 5样例结果输出:2...原创 2021-11-23 09:46:12 · 1368 阅读 · 1 评论 -
【数据结构】图的广度优先遍历BFS 邻接表实现
//无向图的邻接表#include<iostream>#include<queue>using namespace std;const int MAX = 20;struct ArcNode { //边节点 int adjvex; //存储图中节点的下标 ArcNode * next;};typedef struct { int vertex; //存储图中节点的数据 ArcNode * firstEdge; //表头指针} vertexNode[..原创 2021-11-23 09:45:28 · 173 阅读 · 0 评论 -
【数据结构】图的广度优先遍历BFS 邻接矩阵实现
//网图(带权值)的邻接矩阵#include<iostream>#include<cstring>#include<queue>using namespace std;const int INFINIT = 0x3f3f3f3f;const int MAXVAX = 100;template<class T>class MGraph {private: T * vertex; //数组,用来存放顶点信息 int ** arc; //..原创 2021-11-23 09:43:05 · 347 阅读 · 0 评论 -
【数据结构】图的深度优先遍历DFS 邻接矩阵实现
//网图(带权值)的邻接矩阵#include<iostream>using namespace std;const int INFINIT = 0x3f3f3f3f;const int MAXVAX = 100;template<class T>class MGraph {private: T * vertex; //数组,用来存放顶点信息 int ** arc; //二维数组,用来存放邻接矩阵 int vertexNum, arcNum; //顶点数量 边数原创 2021-11-22 19:18:31 · 203 阅读 · 0 评论 -
【数据结构】图的深度优先遍历DFS 邻接表实现
邻接矩阵实现邻接表实现//无向图的邻接表#include<iostream>using namespace std;const int MAX = 20;struct ArcNode { //边节点 int adjvex; //存储图中节点的下标 ArcNode * next;};typedef struct { int vertex; //存储图中节点的数据 ArcNode * firstEdge; //表头指针} vertexNode[MAX];...原创 2021-11-22 09:43:16 · 256 阅读 · 0 评论 -
【数据结构】图 邻接表实现
//无向图的邻接表#include<iostream>using namespace std;const int MAX = 10;struct ArcNode{ //边节点 int adjvex; //存储图中节点的下标 ArcNode * next;};typedef struct { int vertex; //存储图中节点的数据 ArcNode * firstEdge; //表头指针}vertexNode[MAX];class ALGraph{p...原创 2021-11-21 15:27:06 · 260 阅读 · 0 评论 -
【数据结构】图 邻接矩阵实现
开启新的篇章,加油!原创 2021-11-21 08:34:10 · 803 阅读 · 0 评论 -
【数据结构】哈夫曼编码
#include<iostream>#include <limits.h>#include<cstring>using namespace std;struct element{ int weight; int lchild,rchild,parent;};void select(element huffTree[],int n, int &s1,int &s2){ s1 = s2 = 0; int min1 = INT_..原创 2021-11-20 14:29:01 · 345 阅读 · 0 评论 -
【数据结构】哈夫曼树
#include<iostream>#include<stack>#include <limits.h>#include<iomanip>using namespace std;struct element{ int weight; int lchild,rchild,parent;};void select(element huffTree[],int n, int &s1,int &s2){ s1 = ..原创 2021-11-20 08:04:21 · 472 阅读 · 0 评论 -
【数据结构】二叉树遍历的非递归算法
不能放弃,坚持!原创 2021-11-19 13:56:06 · 701 阅读 · 0 评论 -
※【数据结构】线索二叉树
咳咳,让我来宣布一个重大的好消息,现在是2021年11.18 14:37分就在刚刚,我终于成功运行线索二叉树的代码,by myself,without depending on everybody! 而且还意外发现了一些新的东西!!昨天晚上陷入了深度怀疑中,心情很不好。但nothing can beat me!!坚持就是胜利!!接下来我有两个事情要搞明白:1.在main函数中获得类中的private属性 set函数解决2.完成懒猫老师的作业还是要多敲代码,多想多思考多尝试!最重要...原创 2021-11-15 21:33:47 · 783 阅读 · 0 评论 -
※【数据结构】二叉树
二叉树,难。原创 2021-11-14 09:33:03 · 554 阅读 · 0 评论 -
【数据结构】稀疏矩阵(三元组)
TripleMatrix.h//// Created by 63400 on 2021/11/7.//#ifndef LULEARNER_TRIPLEMATRIX_H#define LULEARNER_TRIPLEMATRIX_H#define MAX 100typedef struct{ int row,col; //三元组的行和列 int item; //三元组的值}Triple;class TripleMatrix{private: Trip...原创 2021-11-11 17:43:26 · 1305 阅读 · 0 评论 -
【数据结构】字符串匹配KMP
public class SubstringSearch { /*重点在这个方法这里, 每次pattern匹配到第j个字符的时候发现无法匹配, 不会直接跳转到index = 0的字符,而是和它有相同前缀的字符那边, 具体可以看上面视频,这个讲的不错 。思考一下传统的字符串匹配算法如何实现?O(m*n), 如何改进?是否有重复问题,*/ private int[] computeTemporaryArray(char pattern[]) {原创 2021-11-10 19:36:44 · 79 阅读 · 0 评论 -
【数据结构】字符串匹配BF算法
#include<iostream>using namespace std;int BF(char S[],char T[]);int main(){ char S[100]; char T[100]; cout<<"请输入S字符串:"<<endl; cin>>S; cout<<"请输入T字符串:"<<endl; cin>>T; if(BF(S,T)!= -1原创 2021-11-09 18:43:34 · 340 阅读 · 0 评论 -
※【数据结构】银行排队模拟
银行排队算法学习文档(1)银行排队算法学习文档(2)银行排队模拟(离散事件模拟)PPT文稿原创 2021-11-08 07:41:16 · 705 阅读 · 0 评论 -
【数据结构】链式队列
main.cpp#include <iostream>#include "LinkQueue.h"using namespace std;int main() { LinkQueue<int> Q; Q.enQueue(1); Q.enQueue(2); Q.enQueue(3); Q.displayQueue(); int d; //出队的元素 Q.d..原创 2021-11-07 20:52:41 · 54 阅读 · 0 评论 -
【数据结构】循环队列
main.cpp#include <iostream>#include "CirQueue.h"using namespace std;int main() { try{ CirQueue<int> Queue(3); //Queue.clearQueue(); Queue.displayQueue(); } catch (CirQueue<int>::Out_of_range) .原创 2021-11-07 14:17:29 · 124 阅读 · 0 评论 -
【数据结构】八皇后问题
#include <stdio.h>//全局变量int place[8] = {0}; //用于保存皇后的位置bool flag[8] = { 1, 1, 1, 1, 1, 1, 1, 1}; //皇后占领了哪一列,0表示已经占领,1表示没有占领bool di1[15] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};bool di2[15] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1原创 2021-11-06 19:13:25 · 132 阅读 · 0 评论 -
【数据结构】迷宫问题
经过前辈的指点,程序终于成功运行了。有几个问题:1.小细节非常重要,前辈给我指出来了。2.你输入一个数要按回车或者换行才行,否则会以为你输入一行的一串是一个数。3.熟能生巧,温故知新。main.cpp//// Created by 63400 on 2021/11/1.//#include <iostream>#include "LinkStack.h"using namespace std;const int M = 8; //迷宫长(不包含墙)const..原创 2021-11-06 09:17:31 · 119 阅读 · 0 评论 -
【数据结构】汉诺塔问题
#include <stdio.h>//把n个盘子从x起始柱经由y过渡柱移动到z终点柱void hanoi(int n, char x,char y,char z);//从x柱子移动到z柱子void move(char x,char z);int main(){ int n; printf("请输入柱子的个数:\n"); scanf("%d",&n); hanoi(n,'a','b','c'); return 0; }vo原创 2021-11-05 07:46:06 · 67 阅读 · 0 评论 -
【数据结构】表达式求值
预习文档原创 2021-11-01 09:16:55 · 211 阅读 · 0 评论 -
【数据结构】链栈
sqStack.cpp#include <iostream>#include "Stack.h"using namespace std;int main() {LinkStack<char> s1;s1.push('a');s1.push('b');s1.push('c'); cout << s1.getTop()<<endl; cout<<s1.pop()<<endl; cout<&l原创 2021-11-01 08:52:33 · 81 阅读 · 0 评论 -
【数据结构】双端堆栈
https://www.cnblogs.com/gonghr/p/14508203.html#!comments原创 2021-10-31 14:47:57 · 110 阅读 · 0 评论 -
【数据结构】顺序栈判断一个字符串是否为回文串 作业3
https://www.cnblogs.com/gonghr/p/14508203.html#!comments原创 2021-10-30 21:16:30 · 446 阅读 · 4 评论 -
【数据结构】顺序栈实现字符串处理(作业2)
https://www.cnblogs.com/gonghr/p/14508203.html#!comments原创 2021-10-30 21:14:54 · 610 阅读 · 0 评论 -
【数据结构】用类模板实现顺序栈(带异常)
sqStack.cpp//// Created by 63400 on 2021/10/30.//#include <istream>using namespace std;#include "Stack.h"int main() { Stack<char> s1(2); //或CharStack s1(2); char ch; try { s1.push('a'); s1.push('b');原创 2021-10-30 20:46:24 · 79 阅读 · 0 评论