随笔分类 -  数据结构与算法

摘要:图的遍历 调试版 // 基于C语言的图的遍历 #include <stdlib.h> #include <stdio.h> #define MAX_EDGE 15 #define MAX_SIZE 9 #define MAX_VERTEX 9 typedef int Edge; // 边 typed 阅读全文
posted @ 2020-11-26 17:53 墨狮 阅读(104) 评论(0) 推荐(0)
摘要:定义 头尾相接的顺序存储结构 重难点 1 队列单指针(front指针)存储的不足: 入队是在队尾追加一个元素,复杂度O(1),出队则需要移动剩余的所有元素,复杂度O(n) 2 改为循环队列的两个关键指针: front - 指向队头元素 rear - 指向队尾元素的下一个位置 3 队列空的条件: fr 阅读全文
posted @ 2020-10-11 09:16 墨狮 阅读(153) 评论(0) 推荐(0)
摘要:方式一【大话数据结构】: #include "stdio.h" #include "stdlib.h" #include "io.h" #include "math.h" #include "time.h" #define OK 1 #define ERROR 0 #define TRUE 1 #d 阅读全文
posted @ 2020-09-28 17:27 墨狮 阅读(2109) 评论(0) 推荐(0)
摘要:以下实现的是一个基于数组存储的完全二叉树 完全二叉树特征: 层序存储位置(k, p)与数组位置(i)之间的关系:i = 2^(p-1) + (q -1) 数组中,结点(p)与左子树(i)的位置关系:i = 2*p + 1 数组中,结点(p)与右子树(i)的位置关系:i = 2*p + 2 数组中,子 阅读全文
posted @ 2020-09-21 15:00 墨狮 阅读(799) 评论(0) 推荐(0)
摘要:前序遍历二叉树:ABDHKECFIGJ 中序遍历二叉树:HKDBEAIFCGJ 后序遍历二叉树:KHDEBIFJGCA // 二叉树的链式存储 #include "stdlib.h" #include "stdio.h" #include "io.h" #include "string.h" #in 阅读全文
posted @ 2020-09-18 11:41 墨狮 阅读(433) 评论(0) 推荐(0)
摘要:// 顺序栈 #include <stdlib.h> #include <stdio.h> #define STATUS_TRUE 1 #define STATUS_FALSE 0 #define MAXSIZE 100 typedef int SElemType; /* * ADT - 栈的基本抽 阅读全文
posted @ 2020-08-26 13:57 墨狮 阅读(122) 评论(0) 推荐(0)
摘要:#include <stdlib.h> #include <stdio.h> #define STATUS_OK 0 #define STATUS_FAILED -1 // 定义基本数据结构 // 1 利用大数组定义静态链表,数组由头结点,尾结点,已用链表,备用链表四部分构成 // 2 数组头结点: 阅读全文
posted @ 2020-08-20 21:22 墨狮 阅读(275) 评论(0) 推荐(0)
摘要:// 实现单循环链表 #include <stdlib.h> // 引入标准库与输入输出库 #include <stdio.h> typedef int ElemType; // 定义带头结点的单链表 typedef struct node { ElemType data; struct node* 阅读全文
posted @ 2020-08-20 18:44 墨狮 阅读(417) 评论(0) 推荐(0)
摘要:【https://www.cnblogs.com/lfalex0831/p/9681804.html】 阅读全文
posted @ 2020-05-29 11:55 墨狮 阅读(109) 评论(0) 推荐(0)