数据结构
咸鱼肥美妖娆
我,菜到抠脚。
最近好多水军捏
展开
-
排序 C++
排序插入排序直接插入排序折半插入排序希尔排序交换排序冒泡排序快速排序选择排序简单选择排序堆排序(以大根堆为例)归并排序2-路归并排序基数排序外部排序插入排序将一个数目插入该占据的位置直接插入排序清晰解释:https://blog.csdn.net/weixin_42109012/article/details/91478883代码:#include<iostream>using namespace std;#define Max 20//排序元素个数的最大值typedef原创 2021-06-20 17:43:08 · 70 阅读 · 0 评论 -
两个单链表的合并 C++
#include<iostream>#include<cstdlib>using namespace std;#define OK 1;#define ERROR 0;typedef int Status;typedef int DataType;typedef struct LNode//Linked list=链表{ DataType data; struct LNode *next;}LNode,*LinkList;Status Init原创 2021-06-13 23:48:53 · 1506 阅读 · 1 评论 -
哨兵--顺序的查找
#include<iostream>using namespace std;#define Max 20typedef int DataType;typedef struct{ DataType *data; int lenght;}SqList;void InitList(SqList &L){ L.data=new DataType[Max]; L.lenght=0;}void CreateSqList(SqList &原创 2021-06-14 14:44:55 · 262 阅读 · 0 评论 -
比较得出第一小和第二小
#include<stdio.h>void select(int *c,int *a,int *b,int d){ int i,j,min=c[0],k,t; for(i=0;i<d;i++) if(c[i]<min) { min=c[i]; k=i; } *a=min; t=c[0]; c[0]=c[k]; c[k]=t; mi原创 2021-05-17 21:06:52 · 76 阅读 · 0 评论 -
哈夫曼树的创建
//文件名后缀为.cpp#include <cstdio>#include <cstring>using namespace std;typedef struct{ int weight; int parent,lchild,rchild;}HTNode,*HuffmanTree;void Select(HuffmanTree &HT, int n, int &s1, int &s2){ int minum;原创 2021-05-18 09:19:07 · 415 阅读 · 0 评论 -
汉诺塔问题
ps:han中,第一个char表示盘子出发的柱子,第二个char表示盘子要过渡的柱子,第三个char表示盘子最终到达的柱子。#include<stdio.h>void han(char one,char two,char three,int n){ if(n==1) move(one,three); else { han(one,three,two,n-1); move(one,three); han原创 2021-04-15 21:04:25 · 70 阅读 · 0 评论 -
链栈的基本操作
#include<stdio.h>#include<stdlib.h>#define OK 1#define ERROR 0#define OVERFLOW -2typedef int Status;typedef struct StackNode{ int data; struct StackNode *next;}StackNode,*LinkStack;//;链栈的初始化Status InitStack(LinkStack *s){原创 2021-04-23 19:22:14 · 76 阅读 · 0 评论 -
顺序栈的基本操作
#include<stdio.h>#include<stdlib.h>#define OK 1#define ERROR 0#define OVERFLOW -2#define MAXSIZE 100typedef int Status;//定义结构体typedef struct{ int *base; int *top; int stacksize;}SqStack;//栈的创建Status InitStack(SqStack原创 2021-04-23 18:15:43 · 133 阅读 · 0 评论 -
顺序栈的逆序和顺序输出
#include<stdio.h>#include<stdlib.h>typedef int Status;#define OVERFLOW -1#define ERROR 0#define OK 1#define MAXSIZE 100typedef struct{ int *base; int *top; int stacksize;}SqStack;/**栈的创建**/Status InitStack(SqStack *s)原创 2021-04-15 23:03:00 · 4596 阅读 · 0 评论 -
邻接表——深度优先
/**有向无权邻接表**/#include<iostream>using namespace std;/*************************无向图/网的邻接表的存储表示***********************************/#define Max 10//最大顶点数typedef char VerTexType;//定义顶点类型typedef struct ArcNode{ int adjvex;//该边所连接的顶点的邻接点的下标原创 2021-06-09 21:23:00 · 376 阅读 · 1 评论 -
二叉排序树的创建和查找 C++
/**二叉排序树的查找,如果所要查找的元素在树里面,则输出true,如果不在树里面,则输出false**/#include<iostream>using namespace std;#define EndFlag -1typedef int DataType;typedef struct BSNode//Binary Sort Tree=二叉排序树{ DataType data; struct BSNode *lchild,*rchild;}BSNode,*BS原创 2021-06-14 19:25:19 · 530 阅读 · 0 评论 -
折半查找--顺序表
折半查找又称二分查找。优点:比较次数少,查找速度快,平均性能好;缺点:要求待查表为有序表,且插入删除困难。因此:折半查找方法适用于不经常变动而查找频繁的有序列表。/**在有序顺序表中进行**/#include<iostream>using namespace std;#define Max 20typedef int DataType;typedef struct{ DataType *data; int length;}SqList;void I原创 2021-06-14 15:15:44 · 985 阅读 · 0 评论 -
无向网-邻接矩阵-深度优先
/**创建无向图的邻接矩阵**/#include <cstdlib>//exit#include <iomanip>//swet#include<iostream>//cout,cinusing namespace std;#define MAX 20#define MAXINT 39788//表示无穷大int visited[MAX]={0};//全局变量typedef char DataType;//结构类型--无向图--邻接矩阵typed原创 2021-06-02 22:50:21 · 451 阅读 · 0 评论 -
C语言 单链表 学生信息的取值,定位,删除,插入
#include<stdio.h>#include<stdlib.h>#include<string.H>#define ERROR 0#define OK 1typedef struct{ char no[8]; char name[20]; float score;}stu;typedef struct LNode{ stu data; struct LNode *next;}LNode,*LinkLi原创 2021-04-06 15:57:38 · 656 阅读 · 0 评论 -
C语言 单链表的创建 取值 定位 插入和删除等功能
ps:此单链表的数据为简单整数#include<stdio.h>#include<stdlib.h>#define OK 1#define ERROR 0typedef int Status;typedef int ElemType;typedef struct LNode{ ElemType data; struct LNode *next;}LNode,*LinkList;Status InitList(LinkList *L){原创 2021-03-31 22:57:40 · 413 阅读 · 0 评论