![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构与算法C语言
cskmyjy
水平差,反应慢
展开
-
数据结构与算法 ~ 图 ~ 最短路径 ~ 贝尔曼-福特算法(图采用邻接矩阵储存)
数据结构与算法 ~ 图 ~ 最短路径 ~ 贝尔曼-福特算法(图采用邻接矩阵储存)/*graph---bellman-ford*/#include<stdlib.h>#include<stdio.h>#define MAX 10struct vexnode{ int visited;/*访问标志*/ }vex[MAX...原创 2020-01-18 21:23:01 · 281 阅读 · 0 评论 -
数据结构与算法 ~ 查找 ~ 散列查找(哈希~线性探查法和二次探查法)
数据结构与算法 ~ 查找 ~ 散列查找(哈希~线性探查法和二次探查法)/*search-hash*/#include<math.h>#include<stdio.h>#include<stdlib.h>void Print(int *a){ int i; printf("\n"); for(i=1;i<=a[0];++i) ...原创 2019-11-23 20:57:31 · 1051 阅读 · 0 评论 -
数据结构与算法 ~ 查找 ~ 二叉排序树(创建二叉排序树、查找结点、未查找到结点接入二叉树中)
数据结构与算法 ~ 查找 ~ 二叉排序树/*search--binsorttree*/#include<stdio.h>#include<stdlib.h>struct headnode{ int data; struct treenode *next;};typedef struct headnode *Headnode;struct treeno...原创 2019-11-23 19:59:23 · 1226 阅读 · 0 评论 -
数据结构与算法 ~ 查找 ~ 二分查找
数据结构与算法 ~ 查找 ~ 二分查找/*search---binsearch*/#include<stdio.h>#include<stdlib.h>void binsearch(int *list,int len,int e){ int i,low,high,mid; low=1; high=len; printf("\n===二分查找过程===\n...原创 2019-11-23 16:49:45 · 248 阅读 · 0 评论 -
数据结构与算法 ~ 查找 ~ 顺序查找
数据结构与算法 ~ 查找 ~ 顺序查找/*search--seqlistsearch*/#include<stdio.h>#include<stdlib.h>int seqlistsearch(int *list,int len,int key){ int i,j; list[0]=key; i=len; while(key!=list[i]){ ...原创 2019-11-23 16:12:01 · 309 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 选择排序
数据结构与算法 ~ 排序 ~ 选择排序/*sort--selectsort*/#include<stdio.h>#include<stdlib.h>void selectsort(int *list,int len){ int i,j; for(i=1;i<=len;++i){ j=minkey(list,i,len); if (i!=j){ ...原创 2019-11-23 14:56:19 · 110 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 快速排序
数据结构与算法 ~ 排序 ~ 快速排序/*sort--quicksort*/#include<stdio.h>#include<stdlib.h>void quicksort(int *list,int len){ qsort(list,1,len,len);}/*quicksort*/void qsort(int *list,int low,int h...原创 2019-11-23 13:53:11 · 321 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 直接插入排序
数据结构与算法 ~ 排序 ~ 直接插入排序/*sort--insertsort*/#include<stdio.h>#include<stdlib.h>void insertsort(int *list,int len){ int i,j; for (i=2;i<=len;++i){ if ( list[i]<list[i-1]){ l...原创 2019-11-23 13:02:16 · 138 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 堆排序
数据结构与算法 ~ 排序 ~ 堆排序/*sort--heapsort*/#include<stdlib.h>#include<stdio.h>#define MAX 100int create_heap(int *heap){ int e,length=0; printf("\n=======创建=======\n"); printf("\n请输入数字...原创 2019-11-22 16:07:48 · 116 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 折半插入排序
数据结构与算法 ~ 排序 ~ 折半插入排序/*sort----binsort*/#include<stdio.h>#include<stdlib.h>void Binsort(int *list,int len){ int i,j,k; int mid, low,high; for (i=2;i<=len;++i){ list[0]=lis...原创 2019-11-22 15:44:59 · 144 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 希尔排序
数据结构与算法 ~ 排序 ~ 希尔排序/*sort--shellsort*/#include<stdio.h>#include<stdlib.h>void Print(int *list,int len){ int i; printf ("\n当前排序的结果是:"); for (i=1;i<=len;++i) printf (" %d,",li...原创 2019-11-22 15:11:06 · 220 阅读 · 0 评论 -
数据结构与算法 ~ 排序 ~ 冒泡排序
数据结构与算法 ~ 排序 ~ 冒泡排序#include<stdio.h>#include<stdlib.h>void Print(int *list,int len){ int i; printf ("\n当前排序的结果是 :"); for (i=0;i<len;++i) printf (" %d,",list[i]);}/*Print*/...原创 2019-11-22 14:49:22 · 241 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 最短路径 ~ 迪杰斯特拉算法(图采用邻接矩阵储存)
数据结构与算法 ~ 图 ~ 最短路径 ~ 迪杰斯特拉算法(图采用邻接矩阵储存)/*graph---dijkstra*/#include<stdlib.h>#include<stdio.h>#define MAX 10struct vexnode{ int visited;/*访问标志*/ }vex[MAX];in...原创 2019-11-21 20:48:02 · 771 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 最小生成树 ~ 克鲁斯卡尔算法(图采用邻接表方式存储)
数据结构与算法 ~ 图 ~ 最小生成树 ~ 克鲁斯卡尔算法(图采用邻接表方式存储)/* graph ------adjacency List */#include<stdlib.h>#include<stdio.h>#define MAX 20/*弧结点信息*/struct ArcNode{ int adjvex;/*该弧所指向的顶点的信息*/ i...原创 2019-11-21 19:56:05 · 1081 阅读 · 1 评论 -
数据结构与算法 ~ 图 ~ 最小生成树 ~ 克鲁斯卡尔算法(图采用邻接矩阵方式存储)
数据结构与算法 ~ 图 ~ 最小生成树 ~ 克鲁斯卡尔算法(图采用邻接矩阵方式存储)/*graph---kruskal*/#include<stdlib.h>#include<stdio.h>#define MAX 10/*定义图的顶点*/struct vexnode{ int number; /*顶点所属的集合*/}vex[MAX];/*定义图的弧...原创 2019-11-21 19:07:50 · 876 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 最小生成树 ~ 普里姆算法(图采用邻接矩阵方式存储)
数据结构与算法 ~ 图 ~ 最小生成树 ~ 普里姆算法(图采用邻接矩阵方式存储)/*graph--prim*/#include<stdlib.h>#include<stdio.h>#define MAX 10struct vexnode{ int visited;/*顶点访问标志*/}vex[MAX];int array[MAX][MAX];/*存放权值...原创 2019-11-21 18:47:18 · 680 阅读 · 1 评论 -
数据结构与算法 ~ 图 ~ 图的遍历 ~ 广度优先搜索
数据结构与算法 ~ 图 ~ 图的遍历 ~ 广度优先搜索/* graph ------adjacency List */#include<stdlib.h>#include<stdio.h>#define MAX 20struct ArcNode{ /*弧结点信息*/ int adjvex; ...原创 2019-11-19 23:14:54 · 113 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 图的遍历 ~ 深度优先搜索
数据结构与算法 ~ 图 ~ 图的遍历 ~ 深度优先搜索/* graph ------adjacency List */#include<stdlib.h>#include<stdio.h>#define MAX 20/*弧结点信息*/struct ArcNode{ int adjvex; /*该弧所指向的顶点的信息*/ struct ArcNode...原创 2019-11-19 20:12:22 · 118 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 邻接多重表
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 邻接多重表/* graph-Adjacency MultiList */#include<stdlib.h>#include<stdio.h>#define MAX 20struct EBox{ int ivex,jvex; /*边所依附的两个顶点位置*/ struct EBox *ilink , *...原创 2019-11-19 19:22:23 · 125 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 十字链表
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 十字链表/* graph---orthogonal List*/#include<stdlib.h>#include<stdio.h>#define MAX 20struct ArcBox{ int tailvex;/*该弧的弧尾信息*/ int headvex;/*该弧的弧头信息*/ struct...原创 2019-11-19 18:19:39 · 98 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 数组表示
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 数组表示/* Graph--aray */#include<stdlib.h>#include<stdio.h>#define MAX 10int graph[MAX][MAX];void create_graph(int source,int destination){ graph[source][des...原创 2019-11-18 20:22:06 · 87 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 图的表示和存储 ~ 邻接表
数据结构与算法~图~图的表示和存储~邻接表#include<stdlib.h>#include<stdio.h>#define MAX 20struct ArcNode{ /*弧结点信息*/ int adjvex; /*该弧所指向的顶点的信息*/ struct ArcNode *nextarc; /*指向下一条弧的指针*/};struc...原创 2019-11-18 20:13:09 · 108 阅读 · 0 评论 -
数据结构与算法 ~ 树和二叉树 ~ 非递归的前中序遍历(使用链表存储)
数据结构与算法 ~ 树和二叉树 ~ 非递归的前中序遍历(使用链表存储)/*tree-Traverse no recursion*/#include<stdlib.h>#include<stdio.h>struct headnode{/*头结点*/ int data;/*数据域存放二叉树的结点数*/ struct treenode *next;/*指向二叉树...原创 2019-11-06 00:15:18 · 533 阅读 · 0 评论 -
数据结构与算法 ~ 树和二叉树 ~ 使用链表存储(递归前中后序遍历)
数据结构与算法 ~ 树和二叉树 ~ 使用链表存储,采用递归实现前中后序遍历#include<stdlib.h>#include<stdio.h>/*头结点*/struct headnode{ int data; /*数据域存放二叉树的结点数*/ struct treenode *next;/*指向二叉树的根结点*/};typedef struct h...原创 2019-11-05 00:32:09 · 601 阅读 · 0 评论 -
数据结构与算法 ~ 树和二叉树 ~ 使用数组存储二叉树
数据结构与算法 ~ 树和二叉树 ~ 使用数组存储二叉树/* binary trees--sequence storage express */#include<stdlib.h>#include<stdio.h>#define MAX 100int length=1;void create_bitree(int bitree[]){ int flag,...原创 2019-11-04 20:22:08 · 267 阅读 · 0 评论 -
数据结构与算法 ~ 数组和广义表 ~ 矩阵的相乘
数据结构与算法中数组和广义表的矩阵的相乘.#include<stdlib.h>#include<stdio.h>#define MAX 10struct elem{ int data;/*元素值*/};typedef struct elem Elem;struct matrix{ int row;/*行数*/ int col; /*列数*/ E...原创 2019-10-29 19:20:37 · 491 阅读 · 0 评论 -
数据结构与算法 ~ 数组和广义表 ~ 矩阵的相加
数据结构与算法中数组和广义表的矩阵的相加#include<stdlib.h>#include<stdio.h>#define MAX 10struct elem{ int data; /*元素值*/};typedef struct elem Elem;struct matrix{ int row; /*行数*/ int col;...原创 2019-10-29 18:46:59 · 499 阅读 · 0 评论 -
数据结构与算法 ~ 数组和广义表 ~ 对称矩阵的压缩存储
数据结构与算法中数组和广义表的对称矩阵的压缩存储/*对称矩阵以一维数组进行存储*/#include<stdlib.h>#include<stdio.h>#define MAX 10struct elem{ int data;/*元素值*/};typedef struct elem Elem;struct matrix{ int row;/*行数*/...原创 2019-10-29 17:57:54 · 369 阅读 · 0 评论 -
数据结构与算法 ~ 数组和广义表 ~ 稀疏矩阵的传统转置
数据结构与算法中数组和广义表的 稀疏矩阵的传统转置#include<stdlib.h>#include<stdio.h>#define MAXSIZE 100typedef struct{ int row ,col ;/*该非零元的行下标和列下标*/ int data ;} Triple;typedef struct{ Triple d...原创 2019-10-29 17:32:12 · 205 阅读 · 0 评论 -
数据结构与算法 ~ 数组和广义表 ~ 稀疏矩阵的快速转置
数据结构与算法中数组和广义表的稀疏矩阵的快速转置#include<stdlib.h>#include<stdio.h>#define MAXSIZE 100typedef struct{ int row ,col ; int data ; } Triple;typedef struct{ ...原创 2019-10-29 17:22:56 · 327 阅读 · 0 评论 -
数据结构与算法 ~ 图 ~ 最小生成树 ~ 普里姆算法(图采用邻接表方式存储)
普里姆算法(Prim算法),图论中的一种算法,可在加权连通图里搜索最小生成树。意即由此算法搜索到的边子集所构成的树中,不但包括了连通图里的所有顶点(英语:Vertex (graph theory)),且其所有边的权值之和亦为最小。算法描述:1).输入:一个加权连通图,其中顶点集合为V,边集合为E;2).初始化:Vnew = {x},其中x为集合V中的任一节点(起始点),Enew = {...原创 2019-10-26 00:31:40 · 2656 阅读 · 0 评论 -
数据结构与算法~递归~8皇后问题的C语言实现
/*八皇后问题*/#include<stdio.h>char Chessboard[8][8];//8皇后问题的递归算法部分int N_Queens(int LocX ,int LocY ,int queens){ int i , j ; int result=0; if (queens==8) return 1; /*递归出口*/ ...原创 2019-10-25 00:40:34 · 293 阅读 · 0 评论 -
数据结构与算法~栈的运用~简单表达式的计算(个位数 加减乘除)
使用栈的原理,实现一个简单的表达式计算。演示了:读取字符,判断运算优先级别,压栈,弹栈,计算等功能。 为了简化程序,注意如下几点:1、用一个数据域类型为char的链表,来生成 树栈和符号栈,每次存入数据要从int转换为char,取出数据要从char转化为int,没有处理负数情况,因此计算过程中不要出现负数。2、遇到二位数以上,需要设置标志位,判断读数情况,为了简化,没有做这样的处理...原创 2019-10-24 16:57:29 · 472 阅读 · 0 评论 -
数据结构与算法~串的模式匹配~KMP匹配算法中next值的C语言源代码和测试数据
next值的C语言源代码#include<stdlib.h>#include<stdio.h>#define MAX 20typedef struct { char *ch; int length;}heapstring;/*生成一个串*/void Str_Assign(heapstring *s){ if (!(s->ch=(cha...原创 2019-10-24 13:51:05 · 1327 阅读 · 1 评论 -
数据结构与算法~串的模式匹配~KMP匹配算法中next的快速计算法
在数据结构与算法课程中,串的匹配中,时间和空间消耗最大的是BF蛮力法。基于BF蛮力法的低效率,KMP算法减少了不必要的无效匹配。算法中的核心是要对子串计算next值下面先来看下公式的定义:这个公式比较抽象,我们用这个公式来看看教材上的一个子串的计算过程。模式串的index计算 j 1 2 3 4 5 6 7 8 9 ...原创 2019-10-23 19:22:26 · 1389 阅读 · 0 评论 -
数据结构与算法中~使用顺序存储实现串的基本操作
数据结构与算法中串的顺序表实现#include<stdlib.h>#include<stdio.h>typedef struct { char *ch; int length;}heapstring;void Str_Assign(heapstring *s){ s->ch=(char*)malloc(100*sizeof(char)); p...原创 2019-10-22 22:35:31 · 837 阅读 · 0 评论