考研-数据结构
l0vecamille
nlp算法研一小菜鸡
展开
-
【考研-数据结构】排序算法
排序算法#include<iostream>#include<algorithm>using namespace std;//排序算法(时间复杂度:最好,最坏,平均)//插入排序{O(n),O(n^2),O(n^2)}{稳定}{链表也可使用}void Insert_Sort(int arr[],int n){ int temp = 0,i,j; for(int i = 1;i<n;i++){ if(arr[i]<arr[i-1原创 2021-03-03 23:00:26 · 121 阅读 · 1 评论 -
【考研-数据结构】查找算法
【考研-数据结构】查找算法//查找算法//***1.顺序查找typedef struct{ int *elem; int length;}SSTable;int Search_Seq(SSTable S,int k){ for(int i = 0;i<S.length;i++){ if(S.elem[i] == k){ return i; } } return -1;}//增加哨兵int原创 2021-03-03 22:59:16 · 212 阅读 · 1 评论 -
【考研-数据结构】图的应用
图的应用//图的应用//**1.求最小生成树// (1)Prim算法(时间复杂度O(|V|^2))// (2)kulusiteer(时间复杂度O(|E|*log2|E|))//**2.单源最短路径:// (1)广度优先遍历实现(只能用于无权图)// (2)Dijkstra算法(可以用于有权图,用于负权值的时候会出问题,时间复杂度O(|V|^2))//**3.各个顶点之间的最短路径// (1)Floyd算法(带权图和无权图和负权图都适用,原创 2021-03-03 22:57:35 · 230 阅读 · 1 评论 -
【考研-数据结构】图
【考研-数据结构】图1.图的存储结构和遍历//图//1.邻接矩阵(唯一)//适合稠密图,二维矩阵:用0,1表示边是否存在,带权图用权值代替1//2.邻接表(不唯一)//顺序+链式存储,适合存储稀疏图(表示方法不唯一)//3.十字链表(不唯一)//存储有向图//4.邻接多重表(不唯一)//存储无向图 #include<iostream>#define MaxVertexNum 20#define Max_num 20using namespace std;/原创 2021-02-21 21:01:06 · 243 阅读 · 0 评论 -
【考研-数据结构】树和二叉树
【考研-数据结构】树和二叉树1.二叉树#include <iostream>#define MaxSize 20using namespace std;typedef struct BiTNode{ int data; struct BiTNode *lchild,*rchild; //struct BiTNode* parent;}BiTNode,*BiTree;//链式队列typedef struct LinkNode { BiTNode*原创 2021-02-18 18:07:44 · 257 阅读 · 1 评论 -
【考研-数据结构】串
【考研-数据结构】串串(大总结)//串#include <iostream>#define MaxSize 20using namespace std;typedef struct SString{ char ch[MaxSize]; int length;}SString;//求串长int StrLength(SString S) { return S.length;}//清空bool ClearString(SString& S)原创 2021-02-12 20:11:01 · 206 阅读 · 0 评论 -
【考研-数据结构】栈和队列
【考研-数据结构】栈和队列1.栈静态栈#include <iostream>#define MaxSize 20using namespace std;typedef struct SqStack { int data[MaxSize]; int top;}SqStack;//初始化栈void InitStack(SqStack& s) { s.top = -1;}//入栈bool PushStack(SqStack& s, int e) {原创 2021-02-10 23:32:09 · 185 阅读 · 1 评论 -
【考研-数据结构】线性表
【考研-数据结构】线性表1.顺序表静态空间//静态顺序表#include <iostream>using namespace std;#define Maxsize 10typedef struct list { int data[Maxsize]; int length;}list;//初始化void Init(list& l) { for (int i = 0; i < Maxsize; i++) { l.data[i] = 0; } l.le原创 2021-02-04 22:53:35 · 141 阅读 · 3 评论