数据结构
link_on_line
这个作者很懒,什么都没留下…
展开
-
C语言数据结构学习——二叉树遍历法
#include <stdio.h>#include <string.h>#define TElemType intint top = -1; // top变量时刻表示栈顶元素所在位置//初始化队头和队尾指针开始时都为0int front = 0, rear = 0;//构造结点的结构体typedef struct BiTNode { TElemType data; // 数据域 struct BiTNode* lchild, * rchild; //左右孩子原创 2020-11-29 22:30:46 · 138 阅读 · 0 评论 -
C语言数据结构学习——二叉树链式表示
#include <stdio.h>#include <stdlib.h>#define TElemType inttypedef struct BiTNode { TElemType data; //数据域 struct BiTNode *lchild,*rchild; //左右孩子指针}BiTNode,*BiTree;void createBiTree(BiTree *T) { *T = (BiTNode*)malloc(sizeof(BiTNode));原创 2020-11-29 16:10:58 · 131 阅读 · 0 评论 -
C语言数据结构学习——KMP算法
#include <stdio.h>#include <string.h>#include <stdlib.h>// 1、 写出一个字符串的前缀表// 2、 讨论前缀表中的字符串的最短公共前后缀// 3、 构造前缀表// 4、 根据前缀表匹配字符串void prefix_table(char pattern[], int prefix[], int n) { prefix[0] = 0; int len = 0; int i = 1; whil原创 2020-11-25 22:12:07 · 137 阅读 · 0 评论 -
C语言数据结构学习——BF算法
#include <stdio.h>#include <string.h>// 串普通模式匹配算法的实现函数, 其中B是伪主串, A是伪子串int mate(char * B, char * A) { int i = 0, j = 0; while (i < strlen(B) && j < strlen(A)) { if (B[i] == A[j]) { i ++; j ++; } else { i = i -原创 2020-11-25 10:12:53 · 302 阅读 · 0 评论 -
C语言数据结构学习——链式队列
#include <stdio.h>#include <stdlib.h>typedef struct QNode { int data; struct QNode* next;}QNode;QNode * initQueue() { QNode* queue = (QNode*)malloc(sizeof(QNode)); queue->next = NULL; return queue;}QNode* enQueue(QNode * rear,原创 2020-11-25 10:11:43 · 81 阅读 · 0 评论 -
C语言数据结构学习——顺序队列
#include <stdio.h>#define max 5int enQueue2(int *a, int front, int rear, int data) { if ((rear + 1) % max == front) { printf("空间已满"); return rear; } a[rear % max] = data; rear ++; return rear;}int deQueue2(int *a, int front, int rear)原创 2020-11-25 10:09:52 · 87 阅读 · 0 评论 -
C语言数据结构学习——链栈
#include <stdio.h>#include <stdlib.h>typedef struct LinkStack { int data; struct LinkStack* next;}LinkStack;LinkStack* push(LinkStack * stack, int a) { LinkStack* line = (LinkStack*)malloc(sizeof(LinkStack)); line->data = a; line原创 2020-11-25 10:06:06 · 130 阅读 · 0 评论 -
C语言数据结构学习——顺序栈
#include <stdio.h>int push(int* a, int top, int elem) { a[++top] = elem; return top;}int pop(int * a, int top) { if (top == -1) { printf("空栈"); return -1; } printf("弹栈元素:%d\n", a[top]); top --; return top;}int main() { int a[100];原创 2020-11-25 10:04:55 · 78 阅读 · 0 评论 -
C语言数据结构学习——双向链表
#include <stdio.h>#include <stdlib.h>typedef struct DoubleLinkTable{ struct DoubleLinkTable * prior; int data; struct DoubleLinkTable * next;}DoubleLinkTable;/** * @brief * init double link list * @param head * @return D原创 2020-11-25 10:02:12 · 59 阅读 · 0 评论 -
C语言数据结构学习——循环链表实现约瑟夫环
#include <stdio.h>#include <stdlib.h>typedef struct SingleCycleLinkTable{ int data; struct SingleCycleLinkTable * next;}SingleCycleLinkTable;SingleCycleLinkTable * initSingleCycleLinkTable(int n){ SingleCycleLinkTable * head =原创 2020-11-25 09:58:16 · 191 阅读 · 0 评论 -
C语言数据结构学习——单链表
#include <stdio.h>#include <stdlib.h>typedef struct SingleLinkTable{ int elem; struct SingleLinkTable *next;} SingleLinkTable;/** * @brief * create single link table * @return SingleLinkTable* */SingleLinkTable * initSing原创 2020-11-25 09:44:06 · 109 阅读 · 0 评论 -
C语言数据结构学习——顺序表
#include <stdio.h>#include <stdlib.h>#define Size 5typedef struct SequenceTable{ int * head; int length; int size;} SequenceTable;/** * @brief 初始化顺序表 * * @return SequenceTable */SequenceTable initTable(){ Sequence原创 2020-11-16 22:53:24 · 79 阅读 · 0 评论