![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
BUCT数据结构类库
半山乱步
繁星瞬变,智慧永恒
展开
-
【BUCT数据结构类库】5.5--程序题--Huffman树的建立及编码算法实现
代码改编自哈夫曼树 - wxdjss - 博客园#include<stdio.h>#include<stdlib.h>#define MAXSIZE 30typedef struct node{ int data;//结点数据 struct node *lchild,*rchild;//哈夫曼树的左右孩子指针 struct node *next;//哈夫曼树的结点同时又是单链表的结点,next为单链表的结点指针}BSTree_Link;/..转载 2022-01-03 23:44:45 · 131 阅读 · 0 评论 -
【BUCT数据结构类库】3.2--模式匹配--改进的KMP算法
截图自王道数据结构考研辅导,下面附上了完整代码#include<iostream>#include<string>using namespace std;int Index_kmp(string S,string T,int next[]){ int i=1,j=1; while(i<S.size()&&j<T.size()){ if(j==0||S[i]==T[j]){ i++原创 2022-01-03 20:27:31 · 196 阅读 · 2 评论 -
【BUCT数据结构类库】5.1--程序题--二叉树遍历的递归算法实现
#include <stdio.h>#include <iostream>using namespace std;#define ElemType char//节点声明,数据域、左孩子指针、右孩子指针typedef struct BiTNode{ char data; struct BiTNode *lchild, *rchild;} BiTNode, *BiTree;//先序建立二叉树BiTree CreateBiTree(){.原创 2022-01-03 15:09:03 · 145 阅读 · 0 评论 -
【BUCT数据结构类库】5.3--程序题--二叉树建立算法实现
#include <stdio.h>#include <iostream>using namespace std;#define ElemType char//节点声明,数据域、左孩子指针、右孩子指针typedef struct BiTNode{ char data; struct BiTNode *lchild,*rchild;}BiTNode,*BiTree;//先序建立二叉树BiTree CreateBiTree(){ .原创 2022-01-03 14:38:06 · 110 阅读 · 0 评论 -
【BUCT数据结构类库】3.1--模式匹配--KMP算法
截图自王道数据结构考研复习指导,下面附上代码#include<iostream>#include<string>using namespace std;int Index_kmp(string S,string T,int next[]){ int i=1,j=1; while(i<S.size()&&j<T.size()){ if(j==0||S[i]==T[j]){ i++.原创 2022-01-03 09:20:20 · 99 阅读 · 0 评论 -
【BUCT数据结构类库】2.6--应用题--数制转换问题
#include<iostream>#include<vector>using namespace std;//数制转换void Convert(int n, int base){ vector<int> v; while(n > 0) { v.push_back(n % base); n /= base; } for(int i = v.size() - 1; i >= 0.原创 2022-01-03 08:48:38 · 358 阅读 · 0 评论 -
【BUCT数据结构类库】2.4--链式队列的基本操作
#include<iostream>using namespace std;//链式队列typedef struct LinkNode{ int data; struct LinkNode *next;}LinkNode,*LinkList;//队列初始化void Init(LinkList &L){ L = new LinkNode; L->next = NULL;}//判断队列是否为空bool IsEmpty(Link.原创 2022-01-03 08:47:08 · 440 阅读 · 0 评论 -
【BUCT数据结构类库】2.3--顺序队列的基本操作
#include <iostream>using namespace std;//顺序队列typedef struct Seqlist{ int data[1000]; int front, rear;} Seqlist;//队列初始化void Init(Seqlist &L){ L.front = L.rear = 0;}//判断队列是否为空bool IsEmpty(Seqlist L){ return L.front ==.原创 2022-01-03 00:18:47 · 477 阅读 · 0 评论 -
【BUCT数据结构类库】2.2--链式栈的基本操作
#include<iostream>using namespace std;//链式栈typedef struct Linlnode{ int data; struct Linlnode *next; }Linlnode,*Linlnodeptr;//初始化Linlnodeptr init(Linlnodeptr &L){ L = (Linlnodeptr)malloc(sizeof(Linlnode)); L->next =.原创 2022-01-03 00:00:41 · 469 阅读 · 0 评论 -
【BUCT数据结构类库】2.1--顺序栈的基本操作
#include<iostream>using namespace std;//顺序栈typedef struct sqstack{ int *data; int length;}sqstack;//初始化void init_sqstack(sqstack &S){ S.data = NULL; S.length = 0;}//判断是否为空bool is_empty(sqstack S){ return S.data == NU.原创 2022-01-02 01:05:05 · 252 阅读 · 0 评论 -
【BUCT数据结构类库】1.4--约瑟夫问题
#include<iostream>#include<vector>using namespace std;// 约瑟夫问题//循环链表typedef struct node{ int data; node *next;}*Linklist;// 初始化循环链表void init_Linklist(Linklist &L){ L=new node; L->next=L;}// 判断循环链表是否为空bool is_.原创 2022-01-02 00:58:18 · 235 阅读 · 0 评论 -
【BUCT数据结构类库】1.1--顺序表的基本操作
#include<iostream>using namespace std;// 顺序表typedef struct sqlist{ int *data; int length;}sqlist;// 初始化顺序表void init_sqlist(sqlist &L){ L.data = NULL; L.length = 0;}// 判断顺序表是否为空bool is_empty(sqlist L){ return L.dat.原创 2022-01-01 19:42:21 · 189 阅读 · 0 评论 -
【BUCT数据结构类库】1.2--链表的基本操作
#include<iostream>#include<vector>using namespace std;// 顺序表typedef struct node{ int data; node *next;}*sqlist;// 初始化顺序表void init_sqlist(sqlist &L){ L = NULL;}// 判断顺序表是否为空bool is_empty(sqlist L){ return L == NU.原创 2022-01-01 19:32:34 · 112 阅读 · 0 评论 -
【BUCT数据结构类库】8.3--程序题--选择排序算法实现
#include<iostream>#include<vector>#include<algorithm>using namespace std;//简单选择排序和堆排序void selectSort(vector<int> &a){ int i,j,min; for (i = 1; i < a.size(); i++) { min = i; for (j = i + 1; j .原创 2022-01-01 15:24:58 · 242 阅读 · 0 评论 -
【BUCT数据结构类库】8.2--程序题--交换排序算法实现
#include<iostream>#include<vector>using namespace std;//实现交换排序算法中的起泡排序和快速排序//冒泡排序void bubbleSort(vector<int>& v){ int i, j; for (i = 0; i < v.size() - 1; i++) { for (j = 0; j < v.size() - 1 - i; j++) .原创 2022-01-01 15:03:22 · 231 阅读 · 0 评论 -
【BUCT数据结构类库】8.1--程序题--插入排序算法实现
#include <iostream>#include <vector>#include <algorithm>using namespace std;void print(vector<int> a){ for (int i = 1; i <a.size() ; i++) { cout<<a[i]<<" "; } cout<<endl; }//.原创 2022-01-01 14:31:36 · 3380 阅读 · 0 评论 -
【BUCT数据结构类库】7.3--程序题--动态查找——二叉排序树实现
#include<iostream>using namespace std;//二叉排序树typedef struct Node{ int key; Node *left; Node *right;}*Tree;Tree insert(Tree root, int key){ if (root == NULL) { root = new Node; root->key = key; .原创 2022-01-01 12:04:51 · 175 阅读 · 0 评论 -
【BUCT数据结构类库】7.2--程序题--静态有序表查找——折半查找算法实现
#include<iostream>using namespace std;//折半查找算法int binarySearch(int a[], int n, int key){ int low = 0; int high = n - 1; while (low <= high) { int mid = (low + high) / 2; if (a[mid] == key) return m.原创 2021-12-31 18:23:21 · 96 阅读 · 0 评论 -
【BUCT数据结构类库】6.6--程序题--图的最短路径算法实现
#include<iostream>#include<vector>#include<algorithm>#define inf 0x3f3f3f3fusing namespace std;//通过Dijkstra和Floyd算法,实现图的最短路径;//邻接矩阵法typedef struct Mgraph{ int Vex[100];//顶点数组 int Edge[100][100];//边数组 int vexnum,edgenu.原创 2021-12-31 15:28:19 · 249 阅读 · 0 评论 -
【BUCT数据结构类库】6.3--程序题--图的拓扑排序算法实现
#include<iostream>#include<vector>#include<algorithm>#define inf 0x3f3f3f3fusing namespace std;//图的拓扑排序算法//邻接矩阵法typedef struct Mgraph{ int Vex[100];//顶点数组 int Edge[100][100];//边数组 int vexnum,edgenum;//图的顶点数和边数}Mgrap.原创 2021-12-31 02:03:09 · 134 阅读 · 0 评论 -
【BUCT数据结构类库】6.2--程序题--最小生成树(Prim和Kruskal)算法实现
#include<iostream>#include<vector>#include<algorithm>#define inf 0x3f3f3f3fusing namespace std;//最小生成树 计科A2003 宋佳音//图的存储结构——邻接矩阵法typedef struct Mgraph{ int Vex[100];//顶点数组 int Edge[100][100];//边数组 int vexnum,edgenu...原创 2021-12-31 00:47:17 · 192 阅读 · 0 评论 -
【BUCT数据结构类库】6.1--程序题--图的遍历算法实现
#include<iostream>#include<vector>using namespace std;//图的遍历算法 //图的存储结构——邻接矩阵法typedef struct Mgraph{ int Vex[100];//顶点数组 int Edge[100][100];//边数组 int vexnum,edgenum;//图的顶点数和边数}Mgraph;//图的遍历算法——深度优先搜索void DFS(Mgraph G,int .原创 2021-12-30 21:28:38 · 252 阅读 · 0 评论