数据结构源码笔记(C语言)
C语言描述的数据结构源码笔记。放出来大家参考。
半个冯博士
这个作者很懒,什么都没留下…
展开
-
数据结构源码笔记(C语言描述)汇总
数据结构源码笔记(C语言):英文单词按字典序排序的基数排序数据结构源码笔记(C语言):直接插入排序数据结构源码笔记(C语言):直接选择排序数据结构源码笔记(C语言):置换-选择算法数据结构源码笔记(C语言):Huffman树字符编码数据结构源码笔记(C语言):Josephus问题之顺序表数据结构源码笔记(C语言):Josephus问题之循环链接表数据结构源码笔记(C语言):多项式合并数据结构源码笔记(C语言):二叉树之叶子结点旋转销毁数据结构源码笔记(C语言):哈夫曼树数据结构源码笔记(原创 2020-08-09 20:07:27 · 1523 阅读 · 3 评论 -
数据结构源码笔记(C语言):英文单词按字典序排序的基数排序
//实现英文单词按字典序排序的基数排序算法#include<stdio.h>#include<malloc.h>#include<string.h>#define MaxLen 9 //单词的最大长度#define Radix 27//基数Radix为27,分别对应'','a',....'z'typedef char String[MaxLen+1];//定义String为字符数组类型typedef struct node { String原创 2020-08-09 19:58:30 · 3289 阅读 · 2 评论 -
数据结构源码笔记(C语言):直接插入排序
//实现直接插入排序算法#include<stdio.h>#include<malloc.h>#define MAXE 20typedef int KeyType;typedef char InfoType;typedef struct { KeyType key; InfoType data[10]; }RecType;void InsertSort(RecType r[],int n)//按递增有序进行直接插入排序{ int i,j,k;原创 2020-08-08 00:49:53 · 1122 阅读 · 0 评论 -
数据结构源码笔记(C语言):直接选择排序
//实现直接选择排序算法#include<stdio.h>#include<malloc.h>#define MAXE 20typedef int KeyType;typedef char InfoType[10];typedef struct { KeyType key; InfoType data; }RecType;void SelectSort(RecType r[],int n)// 直接选择排序算法{ int i,j,k,l; Re原创 2020-08-08 00:49:32 · 621 阅读 · 0 评论 -
数据结构源码笔记(C语言):置换-选择算法
//实现置换-选择算法#include<stdio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define MAXSIZE 20typedef int InfoType;//定义其他数据项的类型typedef int KeyType; //定义关键字类型为整型struct RedType //记录类型{ KeyType key;//关键字项 InfoT原创 2020-08-08 00:49:00 · 1312 阅读 · 0 评论 -
数据结构源码笔记(C语言):Huffman树字符编码
#include <stdio.h>#include<string.h>#define N 10 /*待编码字符的个数,即树中叶结点的最大个数*/#define M 2*N-1 /*树中总的结点数目*/typedef struct{ unsigned int weight; unsigned int parent,lchild,rchild;}HTNode; /*树中结点的结构*/typedef struct { char data;原创 2020-08-08 00:48:34 · 628 阅读 · 0 评论 -
数据结构源码笔记(C语言):Josephus问题之顺序表
/*josephus_seq.c*//*Josephus问题: 顺序表实现*/#include <stdio.h>#include <stdlib.h>#define FALSE 0#define TRUE 1typedef int DataType;typedef struct SeqList{ int MAXNUM; int n; int *element;} PSeqList;PSeqList *createNullLi原创 2020-08-08 00:48:05 · 769 阅读 · 0 评论 -
数据结构源码笔记(C语言):Josephus问题之循环链接表
/*josephus_clist.c*//*Josephus问题:循环链接表实现*/#include <stdio.h>#include <stdlib.h>#define FALSE 0#define TRUE 1typedef int DataType; /* 定义元素类型为整型,也可定义为其他类型 */struct Node; /* 单链表结点类型 */typedef struct Node *PNode; /* 结原创 2020-08-08 00:47:27 · 345 阅读 · 0 评论 -
数据结构源码笔记(C语言):多项式合并
#include <stdio.h>#include <stdlib.h>#include <malloc.h>typedef struct node{ int coef; int exp; struct node *next;}PNode;PNode *Creat_Linkst(int n);void PolyAdd(PNode *pa,PNode *pb);void Print_Linkst(PNode *H); int main(原创 2020-08-07 00:07:59 · 644 阅读 · 0 评论 -
数据结构源码笔记(C语言):二叉树之叶子结点旋转销毁
#include<stdio.h>#include<stdlib.h>#define MAXNUM 20int count=0;typedef struct btnode{ int data; struct btnode *lchild,*rchild;}BTNode,*tree;typedef struct{ tree data[MAXNUM+1]; int front,rear;}Queue;BTNode *p[MAXNUM+1];i原创 2020-08-07 00:07:33 · 359 阅读 · 0 评论 -
数据结构源码笔记(C语言):哈夫曼树
#include <stdio.h>#include <stdlib.h>#define MAXINT 2147483647#define MAXNUM 50#define MAXNODE 100struct HtNode //哈夫曼树结点的结构{ int ww; int parent,llink,rlink;};struct HtTree { struct HtNode ht[MAXNODE]; int root;//哈夫曼树根在数组中的下标};原创 2020-08-07 00:07:18 · 607 阅读 · 0 评论 -
数据结构源码笔记(C语言):集合的位向量表示
/*BitSet.c*//*集合的位向量表示:函数实现*/#include <stdio.h>#include <stdlib.h>#define superNum 20#define sonNum 8/*集合的位向量表示:类型和界面定义*/typedef struct { int size; /*字符数组的长度*/ char * array; /*位向量空间。每一数组元素保存8位。*/} BitSet;/*空集合的创建*/BitSet * cr原创 2020-08-07 00:06:12 · 1067 阅读 · 0 评论 -
数据结构源码笔记(C语言):链接队列
/* LinkQueue.c*//*链接队列:函数实现*/#include <stdio.h>#include <stdlib.h>typedef int DataType;struct Node;typedef struct Node *PNode;struct Node /* 结点结构 */{ DataType info; PNode link;};struct LinkQueue /* 链接队列类型定义原创 2020-08-07 00:05:54 · 610 阅读 · 0 评论 -
数据结构源码笔记(C语言):链接栈
/* 链接栈:类型和界面函数声明 *//*链接栈:函数实现*/#include <stdio.h>#include <stdlib.h>typedef int DataType;struct Node; /* 单链表结点 */typedef struct Node *PNode; /* 指向结点的指针类型 */struct Node { /* 单链表结点定义 */ DataType info; PNode link;};str.原创 2020-08-07 00:05:30 · 680 阅读 · 0 评论 -
数据结构源码笔记(C语言):线性表的单链表示
/* LinkList.c*//*线性表的单链表示:函数实现*/#include <stdio.h>#include <stdlib.h>//#include "LinkList.h"/*LinkList.h*//* 线性表的单链表示:类型和界面定义*//* 定义顺序表的元素类型。应根据需要修改 */typedef int DataType;struct Node; /* 单链表结点类型 */typedef struct Node * PNo原创 2020-08-07 00:05:12 · 899 阅读 · 0 评论 -
数据结构源码笔记(C语言):线性表的顺序表示
/* SeqList.c*//*线性表的顺序表示:函数实现*/#include <stdio.h>#include <stdlib.h>//#include "SeqList.h"//#define MAXNUM 100typedef int DataType;typedef struct SeqList{ int MAXNUM; int n; int *element;} PSeqList;PSeqList *createNullList_s原创 2020-08-07 00:04:55 · 882 阅读 · 0 评论 -
数据结构源码笔记(C语言):栈的基本操作
#include <stdio.h>#define MaxSize 100typedef char ElemType;typedef struct{ char stack[MaxSize]; int top;} stacktype;void initstack(stacktype *S){ S->top=-1;} void push(stacktype *S,ElemType x){ if (S->top==MaxSize) p原创 2020-08-07 00:04:35 · 534 阅读 · 0 评论 -
数据结构源码笔记(C语言):中缀表达式
#include <stdio.h>#include <stdlib.h>#include <string.h>#define TRUE 1#define FALSE 0#define MAXNUM 100typedef int DataType;struct BinTreeNode; typedef struct BinTreeNode *PBinTreeNode;struct BinTreeNode{ DataType info; P原创 2020-08-07 00:04:05 · 935 阅读 · 1 评论 -
数据结构源码笔记(C语言):希尔插入排序
//实现希尔插入排序算法#include<stdio.h>#include<malloc.h>#define MAXE 20typedef int KeyType;typedef char InfoType;typedef struct { KeyType key; InfoType data[10]; }RecType;void ShellSort(RecType r[],int n)//{ int i,j,d,k; RecType temp;原创 2020-08-08 00:50:01 · 414 阅读 · 0 评论 -
数据结构源码笔记(C语言):索引文件建立和查找
//实现索引文件建立和查找算法#include<stdio.h>#include<malloc.h>#include<string.h>#include<stdlib.h>#define MaxRec 100//最多的记录个数typedef struct Index //定义索引文件结构{ char num[8];//学号 long offset;//主文件中的记录号}Index;typedef struct sdat原创 2020-08-08 00:50:30 · 3396 阅读 · 0 评论 -
数据结构源码笔记(C语言):冒泡排序
//冒泡排序算法实现#include<stdio.h>#include<malloc.h>#define MAXE 20typedef int KeyType;typedef char InfoType;typedef struct { KeyType key; InfoType data[10]; }RecType;void BubbleSort(RecType r[],int n)//按递增有序进行直接插入排序{ int i,j,k; Rec原创 2020-08-08 00:50:07 · 613 阅读 · 0 评论 -
数据结构源码笔记(C语言):快速排序
//实现快速排序算法#include<stdio.h>#include<malloc.h>#define MAXE 20typedef int KeyType;typedef char InfoType;typedef struct { KeyType key; InfoType data[10]; }RecType;void quickSort(RecType r[],int s,int t)//按递增有序进行直接插入排序{ int i=s,j=.原创 2020-08-08 00:50:14 · 459 阅读 · 0 评论 -
数据结构源码笔记(C语言):可变长度字符串的快速排序
//实现可变长度的字符串序列快速排序算法#include<stdio.h>#include<malloc.h>#include<string.h>#define MaxL 50 //最大的字符串长度typedef struct node //记录类型{ int start;//串的起始位置 int length;}RecType;int StringComp(char s[],RecType a[],int s1,RecType temp)原创 2020-08-06 08:54:10 · 544 阅读 · 0 评论 -
数据结构源码笔记(C语言):基数排序
//实现基数排序算法#include<stdio.h>#include<malloc.h>#include<string.h>#define MAXE 20 //线性表中最多元素个数#define MAXR 10 //基数的最大取值#define MAXD 8 //关键字位数的最大值typedef struct node //记录类型{ char data[MAXD];//记录的关键字定义的字符串 struct node *next; /原创 2020-08-06 08:53:21 · 476 阅读 · 0 评论 -
数据结构源码笔记(C语言):二路归并排序
//实现二路归并排序算法#include<stdio.h>#include<malloc.h>#define MAXE 20 //线性表中最多元素个数typedef int KeyType;typedef char InfoType[10];typedef struct //记录类型{ KeyType key;//关键字项 InfoType data; //其他数据项,类型为InfoType}RecType;void Merge(RecType r[原创 2020-08-06 08:52:30 · 814 阅读 · 0 评论 -
数据结构源码笔记(C语言):堆排序
//实现堆排序算法#include<stdio.h>#include<malloc.h>#define MAXE 20typedef int KeyType;typedef char InfoType[10];typedef struct { KeyType key; InfoType data; }RecType;void DispHeap(RecType r[],int i,int n)//按递增有序进行直接插入排序{ if(i<=n)原创 2020-08-06 08:51:45 · 405 阅读 · 0 评论 -
数据结构源码笔记(C语言):二叉树搜索树Kruskal
#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define INF 32767#define MAVX 100#define MAXE 100typedef int InfoType;typedef int Vertex;typedef struct{ int no; InfoType info;}VertexType;typedef struct{ int edge原创 2020-08-06 00:32:18 · 345 阅读 · 0 评论 -
数据结构源码笔记(C语言):二叉搜索树Prim
#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define INF 32767#define MAVX 100typedef int InfoType;typedef int Vertex;typedef struct{ int no; InfoType info;}VertexType;typedef struct{ int edges[MAVX][MAVX];原创 2020-08-06 00:31:42 · 337 阅读 · 0 评论 -
数据结构源码笔记(C语言):最短路径弗洛伊德算法
#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define INF 32767#define MAVX 100#define MAXE 100typedef int InfoType;typedef int Vertex;typedef struct{ int no; InfoType info;}VertexType;typedef struct{ int edge原创 2020-08-06 00:31:06 · 496 阅读 · 0 评论 -
数据结构源码笔记(C语言):深度、广度优先生成树
#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define INF 32767#define MAVX 100typedef int InfoType;typedef int Vertex;typedef struct{ int no; InfoType info;}VertexType;typedef struct{ int edges[MAVX][MAVX];原创 2020-08-06 00:30:25 · 589 阅读 · 0 评论 -
数据结构源码笔记(C语言):邻接矩阵转化邻接表
#include <stdio.h>#include <stdlib.h>#include <malloc.h>#define INF 32767#define MAVX 100typedef int InfoType;typedef int Vertex;typedef struct{ int no; InfoType info;}VertexType;typedef struct{ int edges[MAVX][MAVX];原创 2020-08-06 00:29:40 · 1278 阅读 · 0 评论 -
数据结构源码笔记(C语言):统计字符串中出现的字符及其次数
//统计一个字符串中出现的字符及其次数#include<stdio.h>#include<malloc.h>#include<string.h>#define MAXWORD 100typedef int KeyType;typedef struct tnode { char ch;//字符 int count;//出现次数 struct tnode *lchild,*rchild;}BTree;void CreaTree(BTree原创 2020-08-06 00:32:39 · 2761 阅读 · 0 评论 -
数据结构源码笔记(C语言):顺序查找
//实现顺序查找的算法#include<stdio.h>#include<malloc.h>#include<malloc.h>#define MAXL 100typedef int KeyType;typedef char InfoType[10];typedef struct { KeyType key;// 关键字的数据类型 InfoType data;//其他数据}NodeType;typedef NodeType SeqLis.原创 2020-08-05 23:46:47 · 558 阅读 · 0 评论 -
数据结构源码笔记(C语言):哈希表的相关运算算法
//实现哈希表的相关运算算法#include<stdio.h>#include<malloc.h>#include<string.h>#define MaxSize 100 //定义最大哈希表长度#define NULLKEY -1//定义空关键字#define DELKEY -2// 定义被删关键字值typedef int KeyType;//关键字类型typedef char * InfoType;//其他数据类型typedef struct原创 2020-08-05 23:45:52 · 1666 阅读 · 0 评论 -
数据结构源码笔记(C语言):分块法查找
//实现分块法查找的算法#include<stdio.h>#include<malloc.h>#include<malloc.h>#define MAXL 100//表中最多的记录个数#define MAXI 20//定义索引表中的最大长度typedef int KeyType;typedef char InfoType[10];typedef struct { KeyType key;//关键字数据类型 InfoType data;//其原创 2020-08-05 23:44:59 · 790 阅读 · 0 评论 -
数据结构源码笔记(C语言):二分查找
//实现二分查找的算法#include<stdio.h>#include<malloc.h>#include<malloc.h>#define MAXL 100//表中最多记录个数typedef int KeyType;typedef char InfoType[10];typedef struct { KeyType key;//关键字类型 InfoType data;//其他数据}NodeType;typedef NodeType原创 2020-08-05 23:43:57 · 511 阅读 · 0 评论 -
数据结构源码笔记(C语言):二叉树遍历
//二叉树遍历#include<stdio.h>#include<malloc.h>#include<malloc.h>#define MaxSize 100typedef char ElemType;typedef struct node{ElemType data;struct node * lchild;struct node * rchild;}BTNode;void CreateBTNode(BTNode * &b,char *s原创 2020-08-05 23:41:48 · 1080 阅读 · 0 评论 -
数据结构源码笔记(C语言):二叉平衡树的相关操作算法
//二叉平衡树的相关运算#include<stdio.h>#include<malloc.h>#include<string.h>typedef char InfoType;typedef int KeyType;typedef struct node { KeyType key; int bf; InfoType data; struct node *lchild,*rchild;}BSTNode;void LeftProcess(B原创 2020-08-05 23:40:58 · 538 阅读 · 0 评论 -
数据结构源码笔记(C语言):二叉排序树的基本操作算法
//二叉排序树的基本运算算法#include<stdio.h>#include<malloc.h>#define MaxSize 100typedef int KeyType;//关键码类型typedef char InfoType;typedef struct node//记录类型{ KeyType key;//关键字项 InfoType data;//其他数据域 struct node *lchild,*rchild;//左右孩子指针}BSTNo原创 2020-08-05 23:40:03 · 971 阅读 · 0 评论 -
数据结构源码笔记(C语言):B树的相关运算算法
//B树的相关运算算法#include<stdio.h>#include<malloc.h>#define MAXM 10//定义B树最大的阶数typedef int KeyType;//关键码类型typedef struct node//B树结点类型定义{ KeyType keynum;//关键字的个数 KeyType key[MAXM];//存放关键字 struct node *parent;//双亲结点指针 struct node *ptr[MA原创 2020-08-05 23:38:22 · 618 阅读 · 0 评论