![](https://img-blog.csdnimg.cn/20190914214020665.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
数据结构
数据结构C语言版
顾道长生'
时人不识凌云木,直待凌云始道高。
展开
-
数据结构:手把手教你写代码系列总结与说明
123原创 2019-09-25 17:48:36 · 4425 阅读 · 6 评论 -
数据结构:二叉树的存储结构
听了国嵌唐老师的课,用C语言实现:BTree.c#include <stdio.h>#include <malloc.h>#include "BTree.h"typedef struct _tag_BTree TBTree;struct _tag_BTree{ int count; BTreeNode* root;};static void re...原创 2019-08-27 17:53:22 · 1115 阅读 · 0 评论 -
数据结构:树的存储结构
听了国嵌唐老师的课,用C语言实现:GTree.h#ifndef _GTREE_H_#define _GTREE_H_typedef void GTree;typedef void GTreeData;typedef void (GTree_Printf)(GTreeData*);/*创建一个树*/ GTree* GTree_Create();/*销毁一个树*/ void...原创 2019-08-26 19:17:46 · 373 阅读 · 0 评论 -
数据结构:归并排序
基本思想:将两个或两个以上的有序序列合并成一个新的有序序列:有序序列V[1] …V[m]和V[m+1] …V[n]V[1] …V[n]这种归并方法称为2路归并MergeSort.c#include <stdio.h>#include <malloc.h>void println(int *array,int len){ int i=0; fo...原创 2019-08-18 10:34:11 · 238 阅读 · 0 评论 -
数据结构:快速排序
基本思想:1)任取待排序序列中的某个数据元素,(:第一个元素) 作为基准,按照该元素的关键字大小将整个序列划分为左右两个子序列: 左侧子序列中所有元素都小于或等于基准元素 右侧子序列中所有元素都大于基准元素 基准元素排在这两个子序列中间分别对这两个子序列重复施行上述方法,直到所有的对象都排在相应位置上为止。QuickSort.c#include <stdio.h&...原创 2019-08-18 10:31:23 · 171 阅读 · 0 评论 -
数据结构:希尔排序
基本思想:将待排序列划分为若干组 将待排序列划分为若干组,在每一组内进行插 入排序,以使整个序列基本有序以使整个序列基本有序, 然后再对整个序列进行插入排序。ShellSort.c#include <stdio.h>void println(int *array,int len){ int i=0; for(i=0; i<len; i++) { p...原创 2019-08-18 10:24:44 · 158 阅读 · 0 评论 -
数据结构:冒泡排序
基本思想:设待排数据元素序列中的元素个数为 n。最多作 n-1趟,i = 1, 2, …, n-1 。在第 i趟中从后向前,j = n-1, n------2, …, i,两两比较V[j-1]和V[j]的关键字。如果发生逆序则交换V[j-1]和V[j]。BubbleSort.c#include <stdio.h>void println(int *array,in...原创 2019-08-13 09:22:12 · 248 阅读 · 0 评论 -
数据结构:插入排序
基本思想:当插入第i (i ≥ 1) 个数据元素时, 前面的V[0], V[1], …, V[i-1]已经排好序这时, 用V[i]的关键字与V[i-1], V[i-2], 的关键字进行比较, , , 找到插入位置即将V[i]插入, 原来位置上的对象向后顺移。InsertionSort.c#include <stdio.h>void println(int *ar...原创 2019-08-13 09:18:01 · 273 阅读 · 0 评论 -
数据结构:选择排序
基本思想:每一趟 (例如第 i 趟,i= 0, 1, …, , , n-2) 在后面 n-i个待排的数据元素中选出关键字最小的元素, 作为有序元素序列的第 i个元素SelectionSort.c#include <stdio.h>void println(int *array,int len){ int i=0; for(i=0;i<len;i++...原创 2019-08-13 09:14:12 · 211 阅读 · 0 评论 -
数据结构:多关键字排序
MulitCompare.c#include<stdio.h>typedef struct _tag_DataElem{ char desc[20]; int key1; int key2;} DataElem;int compare1(DataElem* ld,DataElem* rd){ int ret = 0; if(ld->key1>r...原创 2019-08-12 09:32:33 · 2663 阅读 · 0 评论 -
数据结构:二叉树的遍历(层序遍历、先序遍历、中序遍历、后序遍历)
听了国嵌唐老师的课,用C语言实现如下:main.c#include <stdio.h>#include <stdlib.h>#include "BTree.h"#include "LinkQueue.h"/* run this program using the console pauser or add your own getch, system("pau...原创 2019-08-29 17:26:18 · 348 阅读 · 0 评论 -
数据结构:线索化二叉树
听了国嵌唐老师的课,用C语言实现:main.c#include <stdio.h>#include <stdlib.h>#include "BTree.h"#include "SeqList.h"/* run this program using the console pauser or add your own getch, system("pau...原创 2019-09-02 19:27:55 · 176 阅读 · 0 评论 -
数据结构:图的存储结构一
听了国嵌唐老师的课,用C语言实现如下:MGraph.c#include <stdlib.h>#include <stdio.h>#include "MGraph.h"typedef struct _tag_MGraph{ int count; MVertex** v; int ** matrix;}TMGraph;MGraph* MGraph...原创 2019-09-11 12:29:49 · 314 阅读 · 0 评论 -
数据结构:哈希表的实现
听了国嵌唐老师的课,用C语言实现:main.c#include <stdio.h>#include <stdlib.h>#include "Hash.h" /* run this program using the console pauser or add your own getch, system("pause") or input loop */s...原创 2019-09-25 17:38:27 · 298 阅读 · 0 评论 -
数据结构:二叉排序树
听了国嵌唐老师的课,用C语言实现:BSTree.c#include <stdio.h>#include <malloc.h>#include "BSTree.h"typedef struct _tag_BSTree TBSTree;struct _tag_BSTree{ int count; BSTreeNode* root;};static v...原创 2019-09-25 16:49:21 · 217 阅读 · 0 评论 -
数据结构:由二分查找引出的插值查找
听了国嵌唐老师的课,用C语言实现:OrderSearch.c#include <stdio.h>#include <stdlib.h>#include <time.h>#define SIZE 20/* run this program using the console pauser or add your own getch, system(...原创 2019-09-25 11:38:08 · 193 阅读 · 0 评论 -
数据结构:静态查找(空间换时间,提升效率)
听了国嵌唐老师的课,用C语言实现:AnotherSearch.c#include <stdio.h>#include <stdlib.h>#include <time.h>#define SIZE 20/* run this program using the console pauser or add your own getch, system...原创 2019-09-25 10:50:23 · 387 阅读 · 0 评论 -
数据结构:静态查找和动态查找
听了国嵌唐老师的课,用C语言实现:SearchDemo.c#include <stdio.h>#include <stdlib.h>#include <time.h>#include "SeqList.h"#define SIZE 20/* run this program using the console pauser or add your...原创 2019-09-25 10:00:49 · 850 阅读 · 0 评论 -
数据结构:最短路径_Floyd
算法步骤:C语言实现如下:输入:Floyd.c#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */#define VNUM 5#...原创 2019-09-23 17:09:17 · 247 阅读 · 0 评论 -
数据结构:最短路径_Dijkstra
算法步骤:C语言实现如下:Dijkstra.c#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */#define VNUM 5#de...原创 2019-09-18 11:33:22 · 359 阅读 · 0 评论 -
数据结构:最小连通网-Prime算法
Prime算法:C语言实现如下:#include <stdio.h>#include <stdlib.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */#define VNUM 9#define MV...原创 2019-09-16 18:30:58 · 474 阅读 · 0 评论 -
数据结构:图的遍历(dfs、bfs)
听了国嵌唐老师的课,用C语言实现如下:广度优先遍历LGraph.h#ifndef _LGRAPH_H_#define _LGRAPH_H_typedef void LGraph;typedef void LVertex;typedef void (LGraph_Printf)(LVertex*);LGraph* LGraph_Create(LVertex** v, in...原创 2019-09-16 12:28:28 · 275 阅读 · 0 评论 -
数据结构:队列的特别实现(两个栈)
听了国嵌唐老师的课,用C语言实现如下:SQueue.c#include <stdio.h>#include <malloc.h>#include "LinkStack.h"#include "SQueue.h"typedef struct _tag_SQueue{ LinkStack* inStack; LinkStack* outStack;}T...原创 2019-08-11 09:47:13 · 294 阅读 · 0 评论 -
数据结构:链式队列的优化实现
听了国嵌唐老师的课,用C语言实现如下:LinkQueue.h#ifndef _LINKQUEUE_H_#define _LINKQUEUE_H_typedef void LinkQueue;LinkQueue* LinkQueue_Create();void LinkQueue_Destroy(LinkQueue* queue);void LinkQueue_Clear(L...原创 2019-08-10 09:22:42 · 206 阅读 · 0 评论 -
数据结构:队列的顺序优化实现
听了国嵌唐老师的课,用C语言实现如下:SeqQueue.c#include <stdio.h>#include <malloc.h> #include "SeqQueue.h"typedef unsigned int TSeqQueueNode;typedef struct _tag_SeqQueue{ int capacity; int leng...原创 2019-08-09 20:45:27 · 317 阅读 · 0 评论 -
数据结构:线性表的顺序存储结构
听了国嵌唐老师的课,用C语言实现:SeqList.h#ifndef _SEQLIST_H_#define _SEQLIST_H_typedef void SeqList;typedef void SeqListNode;SeqList* SeqList_Create(int capacity);//创建并返回一个空的线性表void SeqList_Destory(SeqLis...原创 2019-08-01 15:47:10 · 355 阅读 · 0 评论 -
数据结构:栈的应用_符号匹配
算法步骤算法思路:从第一个字符开始扫描当遇见普通字符时忽略,当遇见左符号时压入栈中当遇见右符号时从栈中弹出栈顶符号进行匹配 匹配成功:继续读入下一个字符 匹配失败:立即停止,并报错结束: 成功:所有字符扫描完毕,且栈为空 失败:匹配失败或所有字符扫描完毕但栈非空算法框架scanner(code){ 创建栈 S; i = 0; while(code[i]!='\0'...原创 2019-08-05 16:59:27 · 993 阅读 · 0 评论 -
数据结构:链式栈
听了国嵌唐老师的课,用C语言实现如下:LinkList.c#include <stdio.h>#include <malloc.h>#include "LinkList.h"typedef struct _tag_LinkList{ LinkListNode header; int length;}TLinkList;LinkList* LinkL...原创 2019-08-05 15:41:05 · 340 阅读 · 0 评论 -
数据结构:顺序栈
听了国嵌唐老师的课,用C语言实现如下:原创 2019-08-05 15:01:16 · 328 阅读 · 0 评论 -
数据结构:双向链表
听了国嵌唐老师的课,用C语言实现:DLinkList.h#ifndef _DLINKLIST_H_#define _DLINKLIST_H_typedef void DLinkList;typedef struct _tag_DLinkListNode DLinkListNode;struct _tag_DLinkListNode{ DLinkListNode* next; ...原创 2019-08-03 09:34:24 · 173 阅读 · 0 评论 -
数据结构:栈的应用_表达式计算
中缀转后缀算法步骤: 遍历中缀表达式中的数字和符号 对于数字:直接输出 :直接输出 对于符号:• 左括号:进栈 :进栈• 符号:与栈顶符号进行优先级比较 :与栈顶符号进行优先级比较• 栈顶符号优先级低:进栈 :进栈• 栈顶符号优先级不低:将栈顶符号弹出并输出 :将栈顶符号弹出并输出,之后进栈 ,之后进栈• 右括号:将栈顶符号弹出并输出 :将栈顶符号弹出并输出,直到匹配左括号 ...原创 2019-08-05 19:03:19 · 609 阅读 · 0 评论 -
数据结构:线性表的链式存储结构
听了国嵌唐老师的课,用C语言实现:LinkList.h#ifndef _LINKLIST_H_#define _LINKLIST_H_typedef void LinkList;typedef struct _tag_LinkListNode LinkListNode;struct _tag_LinkListNode{ LinkListNode* next;};LinkL...原创 2019-08-01 17:17:51 · 315 阅读 · 0 评论 -
数据结构:队列的链式实现
听了国嵌唐老师的课,用C语言实现如下:LinkQueue.c#include <malloc.h>#include <stdio.h>#include "LinkList.h"#include "LinkQueue.h"typedef struct _tag_LinkQueueNode{ LinkListNode header; void* item;...原创 2019-08-09 15:58:02 · 281 阅读 · 0 评论 -
数据结构:队列的顺序实现
听了国嵌唐老师的课,用C语言实现如下:SeqQueue.h#ifndef _SEQQUEUE_H_#define _SEQQUEUE_H_typedef void SeqQueue;SeqQueue* SeqQueue_Create(int capacity);void SeqQueue_Destroy(SeqQueue* queue);void SeqQueue_Clea...原创 2019-08-09 15:13:59 · 333 阅读 · 0 评论 -
数据结构:递归应用_八皇后问题
算法思路... 初始化:i = 1 :i = 1... 初始化:j = 1 :j = 1... 从第iiii行开始 i行开始,恢复 ,恢复jjjj的当前值 j的当前值,判断第 ,判断第jjjj个位置 j个位置a.a.a. 位置jjjj可放入皇后 j可放入皇后:标记位置 :标记位置(i, j), (i, j),, i++ i++ i++,,,转步骤 转步骤222b.b.b. 位置jjjj不...原创 2019-08-09 09:56:23 · 256 阅读 · 0 评论 -
数据结构:递归实现全排列
permutation.c#include <stdio.h>void permutation(char s[],int b,int e){ if((0<=b)&&(b<=e)) { if(b==e) { printf("%s\n",s); } else { int i = 0; for(i=b;i&...原创 2019-08-09 09:12:26 · 536 阅读 · 0 评论 -
数据结构:汉诺塔
hanoi.c#include <stdio.h>void hanoi(int n,char a,char b,char c){ if(n>0) { if(n==1) { printf("%c->%c\n",a,c); } else { hanoi(n-1,a,c,b); printf("%c->%c\n",a...原创 2019-08-09 09:10:00 · 877 阅读 · 0 评论 -
数据结构:strlen函数的递归实现
strlen.c#include <stdio.h>int strlen(const char* s){ if(s==NULL) { return -1; } else if(*s=='\0') { return 0; } else { return strlen(s+1)+1; }}int main(){ printf("strlen(...原创 2019-08-09 09:08:08 · 367 阅读 · 0 评论 -
数据结构:斐波那契数列
fibonacci.c#include <stdio.h>int fibonacci(int n){ if(n>1) { return fibonacci(n-1)+fibonacci(n-2); } else if(n==1) { return 1; } else if(n==0) { return 0; }}int main(){...原创 2019-08-09 08:56:36 · 1059 阅读 · 0 评论 -
数据结构:递归实现字符串的逆序
#include <stdio.h>void reverse(char *s){ if((s!=NULL)&&(*s!='\0')) { reverse(s+1); printf("%c",*s); }}int main(){ reverse("12345"); printf("\n"); return 0;} 运行...原创 2019-08-08 21:35:51 · 655 阅读 · 0 评论