![](https://img-blog.csdnimg.cn/20201014180756922.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
ChrisKyrie
这个作者很懒,什么都没留下…
展开
-
汉诺塔问题
#include <stdio.h>void Honia (int n, char a, char b, char c);int count;//统计移动次数int main (){ int n; count = 0; scanf("%d", &n); Honia(n, 'a', 'b', 'c'); printf("%d\n...原创 2018-03-17 13:34:59 · 112 阅读 · 0 评论 -
图-领接表
#include #include #define MAXSIZE 20typedef struct EdgeNode{ int adjvex; int weight; struct EdgeNode *next;}EdgeNode;typedef struct VextexNode{ int data; EdgeNode *firs原创 2018-01-18 09:54:42 · 446 阅读 · 0 评论 -
图-邻接矩阵
#include #include #define MAXSIZE 20#define INITVALUE 65535typedef struct{ char vexs[MAXSIZE]; int arcs[MAXSIZE][MAXSIZE]; int numVexs, numArcs;}Graph;int LocatePos (Grap原创 2018-01-17 08:45:28 · 133 阅读 · 0 评论 -
双向链表
#include #include struct stu{ int data; struct stu *next; struct stu *last;};struct stu *CreatList (){ int data; struct stu *p, *head, *tail; head = tail = NULL; sc原创 2018-01-15 19:43:21 · 100 阅读 · 0 评论 -
链表
#include #include #include struct stud{ int num; struct stud *next;};struct stud *Creat_List ();void Print_List (struct stud *head);struct stud *Insert_List (struct stud *head, int p原创 2018-01-06 10:29:18 · 139 阅读 · 0 评论 -
广义表
#include <stdio.h>#include <stdlib.h>struct LNode{ int tag; /*tag = 0代表原子, tag = 1代表子表*/ union { char data; struct LNode *sublist; /*定...原创 2018-03-24 16:44:48 · 140 阅读 · 0 评论 -
线索二叉树
二叉树的线索化的主要思想是将为使用的左右子树的指针利用,左指针指向前驱节点,右指针指向后继节点。#include <stdio.h>#include <stdlib.h>typedef enum //定义线索二叉树标志{ Link, Thread}PointerTag;typedef struct BiNode{ ...原创 2018-03-31 13:31:21 · 130 阅读 · 0 评论 -
最小生成树与DFS
1、普里姆算法:https://www.cnblogs.com/biyeymyhjob/archive/2012/07/30/2615542.html2、Prim算法核心:在当前已经遍历到的权值中选择最小的权值生成树3、克鲁斯卡尔算法核心:将权值从小到大依次选取相应的边,并且判断这两个点是否属于同一个连通分量。4、深度优先搜索(DFS)核心:建立visited数组判断结点是否遍历到。#includ...原创 2018-01-19 08:42:29 · 1203 阅读 · 0 评论 -
最短路径
最短路径有两种算法:Dijkstra(迪杰斯特拉算法)和Floyd(佛洛伊德)算法Dijkstra算法:类似于Prim算法,通过在已经遍历到的边中寻找到最小值,不同的是Prim算法寻找的是边权值最小的值,Dijkstra算法找的是权值和最小的值。Floyd算法:通过遍历整个结点,循环寻找每个顶点到每个顶点的最小权值。首选:Dijkstra算法,当需要求每个顶点到每个顶点的最短路径时,Floyd算法...原创 2018-04-10 16:16:13 · 166 阅读 · 0 评论 -
赫夫曼编码
#define MAXSIZE 50#include<string.h>#include<stdio.h>typedef struct{char data;/*结点值*/int weight;/*权值*/int parent;/*父结点*/int left;/*左结点*/int right;/*右结点*/int flag;/*标志位*/}huffnod...转载 2018-04-03 14:21:51 · 247 阅读 · 0 评论 -
赫夫曼树与赫夫曼编码
赫夫曼树,又称最优二叉树。它的最优体现在每个结点的权值与它的路径长度的乘积之和最小。具体定义参考博客:https://blog.csdn.net/heart_love/article/details/50901943赫夫曼树的构造原理非常简单,每次在当前的树中找到节点权值最小的两个节点分别作为左右子树,他们双亲的权值就是这两个左右孩子的权值之和。循环构造,直到生成一棵树。赫夫曼编码就是在赫夫曼树的...原创 2018-04-03 14:25:54 · 271 阅读 · 0 评论 -
斐波纳查找
步骤:1、查找数值长度在斐波那契数中的位置2、补全数组3、查找#include <stdio.h>#include <algorithm>using namespace std;int main (){ int arry[20], i, low, high, mid, k, key; int f[10]; f[0] = 0; f[1...原创 2018-01-26 10:35:17 · 178 阅读 · 0 评论 -
字符串的朴素匹配法
#include #include #include int main (){ char s1[20], s2[20]; int m, n, i, j, k; scanf("%s", s1); scanf("%s", s2); m = strlen(s1); n = strlen(s2); for(i = 0; i < m; i++原创 2018-01-19 11:15:42 · 168 阅读 · 0 评论 -
KMP算法
关于KMP算法(看毛片算法),自己刚开始学习的时候一直不理解。主演是算法中的回溯部分。至于KMP算法原理我这里就不重复讲解了,网上有大量的讲解。而我认为KMP算法的核心就是理解它的回溯原理。首先是字串本身的回溯,即求next数组。而我之前一直不理解的一句算法就是下面代码中标记红色的部分。之前的疑问就是,既然T[i]!=T[j],那么为什么不从j-1处比较。现在想想当时的想法是错误的,如果从j-1处...原创 2018-01-20 08:41:30 · 293 阅读 · 0 评论 -
链表插入字母
#include #include #include typedef struct List{ char str; struct List *next;}List;List *CreatList (){ List *head, *tail, *p; char str; str = getchar(); head = tail =原创 2018-01-20 14:26:47 · 472 阅读 · 0 评论 -
栈的应用-进制转化
#include <stdio.h>#include <stdlib.h>#define STACKSIZE 10#define RADIX 16typedef struct{ int *base; int *top; int stack_size;}SqStack;SqStack CreatStack ()...原创 2018-03-15 19:10:04 · 167 阅读 · 0 评论 -
静态链表
#include struct list{ int data; int cur;}SListLink[100];void CreatList (struct list *table){ int i, j; i = 0; for(j = 0; j < 5; j++) { scanf("%d%d", &(table[i].d原创 2018-03-13 16:29:39 · 523 阅读 · 0 评论 -
基数排序
#include <stdio.h>#include <math.h>#include <stdlib.h>#define RADIX_10 10 //0~9空间#define KEY_10 10 //关键字位数(数据最大位数)int GetPos (int num, int pos) //获取关键字{ i...原创 2018-03-03 09:22:25 · 101 阅读 · 0 评论 -
快速排序
快速排序算法:#include #define MAXSIZE 20typedef struct{ int r[MAXSIZE]; int length;}SqList;void swap (SqList *L, int i, int j){ int temp; temp = L->r[i]; L->r[i] = L->r[j];原创 2018-02-28 13:57:12 · 244 阅读 · 0 评论 -
堆排序
#include <stdio.h>#define MAXSIZE 20typedef struct{ int r[MAXSIZE]; int length;}SqList;void swap (SqList *L, int i, int j){ L->r[i] = L->r[i] + L->r[j]; L-&g...原创 2018-02-28 09:37:33 · 108 阅读 · 0 评论 -
希尔排序
#include <stdio.h>#define MAXSIZE 20typedef struct{ int r[MAXSIZE+1]; int length;}SqList;int main (){ SqList L; int i, j, increasement; scanf("%d", &(L.length...原创 2018-02-27 08:57:16 · 120 阅读 · 0 评论 -
直接插入排序
#include <stdio.h>#define MAXSIZE 20typedef struct{ int r[MAXSIZE+1]; int length;}SqList;void swapvalue (SqList *L, int i, int j){ int temp; temp = L->r[i]; L-&...原创 2018-02-27 08:23:24 · 106 阅读 · 0 评论 -
冒泡排序
常规冒泡排序:#include <stdio.h>#define MAXSIZE 20#define TRUE 1#define FALSE 0typedef struct{ int r[MAXSIZE+1]; int Length;}SqList;void swapvalue (SqList *L, int i, int j)...原创 2018-02-26 11:45:08 · 86 阅读 · 0 评论 -
哈希表操作
#include #include #define HASHSIZE 12#define NULLKEY -32768#define SUCESS 1#define FAILED 0/*哈希表定义*/typedef struct{ int *elem; int count;}HasHTable;int m = 0;//散列原创 2018-02-01 11:22:49 · 227 阅读 · 0 评论 -
二分法查找
#include int main (){ int n, low, high, count, mid; low = 0; high = 100; count = 0; printf("Enter n:"); scanf("%d", &n); while(low <= high) { count++; mid = (l原创 2018-01-25 08:28:14 · 190 阅读 · 0 评论 -
最短路径-Floyd算法
#include #define MAXSIZE 20#define INITVALUE 65535typedef struct{ int vexs[MAXSIZE]; int arcs[MAXSIZE][MAXSIZE]; int vexNum, arcnum;}Graph;typedef int PathMin[MAXSIZE][MAXSI原创 2018-01-23 19:37:24 · 180 阅读 · 0 评论 -
二叉排序树基本操作
二叉排序树,顾名思义,是一种排列好顺序的二叉树。它的排序规则是:每个结点的左子树上的值都比它本身的值小,右子树上的值都比它本身的值大。#include <stdio.h>#include <stdlib.h>#define TRUE 1#define FALSE 0typedef struct BiNode{ int data; ...原创 2018-04-13 14:40:07 · 1442 阅读 · 0 评论