diff --git a/docs/.vuepress/config/plugins.config.ts b/docs/.vuepress/config/plugins.config.ts index 16295af..a0393f8 100644 --- a/docs/.vuepress/config/plugins.config.ts +++ b/docs/.vuepress/config/plugins.config.ts @@ -14,21 +14,21 @@ export default { // HelloWorld: path.resolve(__dirname, '../components/HelloWorld.vue') // } }), - // searchProPlugin({ - // // 索引全部内容 - // indexContent: true, - // // 为分类和标签添加索引 - // customFields: [ - // { - // getter: (page: any) => page.frontmatter.category, - // formatter: "分类:$content", - // }, - // { - // getter: (page) => page.frontmatter.tag, - // formatter: "标签:$content", - // }, - // ], - // }), + searchProPlugin({ + // 索引全部内容 + indexContent: true, + // 为分类和标签添加索引 + customFields: [ + { + getter: (page: any) => page.frontmatter.category, + formatter: "分类:$content", + }, + { + getter: (page) => page.frontmatter.tag, + formatter: "标签:$content", + }, + ], + }), // // md文档增强 // mdEnhancePlugin({ // // 文件导入 diff --git a/docs/.vuepress/styles/index.scss b/docs/.vuepress/styles/index.scss index ae419e5..b4b1536 100644 --- a/docs/.vuepress/styles/index.scss +++ b/docs/.vuepress/styles/index.scss @@ -12,33 +12,6 @@ visibility: hidden; // 占位隐藏 } -.DocSearch-Button-Keys { - visibility: hidden -} - -// 首页title描述 -.home .hero .description { - max-width: fit-content; -} - -// 搜索框 -#docsearch-container > button { - border-radius: 5px; -} - -.code-group__nav-tab-active { - color: var(--c-brand) -} - -.open-info-div { - text-align: center; - align-content: center; - - a { - margin: 5px; - } -} - // 全站主题色 :root { diff --git a/docs/manuscripts/ds/ds.sidebar.ts b/docs/manuscripts/ds/ds.sidebar.ts index 2f137da..9b2c6b3 100644 --- a/docs/manuscripts/ds/ds.sidebar.ts +++ b/docs/manuscripts/ds/ds.sidebar.ts @@ -1,39 +1,39 @@ export const dsSidebar = [ { text: '基础入门', - prefix: 'basic-introduction', + prefix: '基础入门', collapsible: false, children: [ { text: '基本概念', - link: '1.basic_concepts.md' + link: '1.基本概念.md' }, { - text: '数据结构三要素', - link: '2.three_elements_of_data_structure.md' + text: '三要素', + link: '2.三要素.md' }, { text: '算法和算法评价', - link: '3.algorithm_and_algorithm_evaluation.md' + link: '3.算法和算法评价.md' } ] }, { text: '线性表', + prefix: '线性表', collapsible: false, - prefix: 'linear-table', children: [ { text: '基础概念和操作', - link: '1.basic_concept_and_operation.md' + link: '1.基础概念和操作.md' }, { text: '顺序表示', - link: '2.sequential_representation.md' + link: '2.顺序表示.md' }, { text: '链式表示', - link: '3.chained_representation.md' + link: '3.链式表示.md' }, { text: '一些总结', diff --git a/docs/manuscripts/ds/linear-table/2.sequential_representation.md b/docs/manuscripts/ds/linear-table/2.sequential_representation.md deleted file mode 100644 index 3cd1ed8..0000000 --- a/docs/manuscripts/ds/linear-table/2.sequential_representation.md +++ /dev/null @@ -1,237 +0,0 @@ -# 线性表的顺序表示 - -```mindmap -root(数据结构三要素) - 逻辑结构 - 存储(物理)结构 - 顺序存储 - 链式存储 - 索引存储 - 散列(Hash)存储 - 数据的运算 -``` - -### 定义 - -`顺序表`:顺序存储的线性表,**是用一组地址连续的存储单元,依次存储线性表中的数据元素,使得在逻辑上相邻的两个元素在物理位置上也相邻。** - -顺序表中的元素的逻辑顺序与实际的物理位置相同 - -注意: - -- 线性表中的元素的位序是从1开始的,例如1、2、3... -- 数组中的元素的下标是从0开始的,例如0、1、2... - -```c -# define MaxSize 20 // 定义常量MaxSize 用来声明顺序表的最大长度 - -// 线性表结构体定义【ElemType用来代指顺序表中元素的类型,例如高级语言中的int、string....】 -typedef struct{ - ElemType data[MaxSize]; // 顺序表的元素 - int length; // 顺序表的长度 -}SqList - -``` - -#### 存储分配 - -`静态分配`:数组的大小和空间都是实现确定好的,一旦存储空间占满就会产生溢出,直接导致程序崩溃。(有点内存不够,宕机重启的意思....) - -`动态分配`:存储数据的空间在程序执行过程中通过`动态存储分配语句`分配的,即便是数据空间占满,也可以另外开辟一块更大的空间,来替换原来的存储空间,满足扩充数据空间的目的。(有点动态规划的意思....)最重要的是:**不需要像静态分配那样,一次性地固定线性表的空间和大小** - -```c -#define InitSize 100 // 表长度初始化 - - -// 动态分配数组顺序表的结构体定义 -typedef struct{ - ElemType *data; // 动态分配数组的指针 - int MaxSize,length; // 数组的最大容量和当前元素个数 -}SqList; - -``` - -动态分配语句 - -```C -// C语言中 - -L.data=(ElemType*)malloc(sizeof(ElemType)*InitSize); - - -// C++ 中 - -L.data=new ElemType[InitSize]; - -``` - -`malloc()函数`: 指针型函数,返回的指针指向该分配域的开头的位置。作用是在内存的动态存储区中分配一个长度为size的连续空间。[百度百科](https://baike.baidu.com/item/malloc%E5%87%BD%E6%95%B0/8582146?fr=aladdin) - -**动态分配不是链式存储,而是属于顺序存储结构**,动态分配的物理结构没有改变,依然是随机存取的方式。只是分配的空间大小可以在运行时决定; - -#### 顺序表的特点 - -- 随机访问【这是最主要的特点】,通过存储起始地址和元素序号O(1)时间内访问指定元素。 -- 存储密度高,没有结点只存储数据元素,不像索引存储那样,还需要索引表什么的.. -- 逻辑上相邻的元素物理上也相邻,插入和删除需要移动大量元素 - -### 基本操作 - -#### 插入 - -在顺序表L的第i(1≤i≤L.length+1)个位置插入新的元素e - -- 第一步:如果i非法,则直接返回false,插入失败,结束插入过程 -- 第二步:i正常,将表的第i个元素以及后面的所有元素都像有移动一个位置,在腾出来的空位置插入元素e -- 第三步:顺序表插入成功,返回true - -注意:先判空和临界值,提高算法健壮性 - -```cpp - -/* - * 顺序表的插入操作 - * - */ -bool ListInsert(SqList &L, int i, ElemType e){ - - // i非法 i=1 表头 i=L.length+1 表尾巴 - if(i<1||i>L.length+1){ - return false; - } - - // 存储空间满,无法插入 - if(L.length >= MaxSize){ - return false; - } - - // 遍历,将位置元素往后移动,注意从后往前循环,避免值被覆盖 - for(int j=L.length; j>=i;j--){ - L.data[j]=L.data[j-1]; - } - - // 此时,表L中的第i个元素和第i+1元素素值一样,将新元素存入i位置即可 - - // 第i个元素,对应的位置角标为i-1 - L.data[i-1]=e; - - // 表长度加1 - L.length++; - - // 返回插入成功 - return true; -} - -``` - -注意:区别顺序表中的位序和角标; - -**时间复杂度** - -- 最好情况:在表尾插入,元素向后移动循环没有执行,时间复杂度O(1); -- 最坏情况:在表头插入,元素后移循环执行n次,时间复杂度为O(n); -- 平均情况:随机插入,平均次数为:n/2,对应的平均复杂度为O(n); - -**线性表插入算法的平均时间复杂度为:O(n)** - -> Tips: 需要根据实现代码理解循环为什么是从后往前来实现元素后移,通过for循环可以很明显的看出表尾插入快,表头插入慢 - -#### 删除 - -删除顺序表L中第i(1≤i≤L.length+1)个位置的元素 - -- 成功,返回true,将被删除的元素用引用变量返回; -- 失败,返回false - -```cpp - -/* - * 顺序表的删除操作 - * - */ -bool ListDelete(SqList &L, int i, ElemType &e){ - - // i非法 i=1 表头 i=L.length+1 表尾巴 - if(i<1||i>L.length+1){ - return false; - } - - // 存储空间满,无法插入 - if(L.length >= MaxSize){ - return false; - } - - // 引用变量e赋值 - e=L.data[i-1] - - // 遍历,第i个元素后面的往前移动 - for(int j=i; j<=L.length;j++){ - // 从第i个元素开始,角标从i-1开始 - L.data[j-1]=L.data[j]; - } - - // 此时,表L中的表尾元素和倒数第二个元素值一样,将表的长度-1 - - // 表长度减1 - L.length--; - - // 返回删除成功 - return true; -} - -``` - -从这里来看,删除、插入元素都会涉及到大量的元素的移动(最好情况例外),总结而言: - -- 元素从后往前移,循环从前往后遍历 -- 元素从前往后移,循环从后往前遍历 - -**时间复杂度:** - -- 最好情况:删除表尾元素,不需要移动任何元素,时间复杂度为O(1); -- 最坏情况:删除表头元素,需要移动除第一个元素外的所有元素,时间复杂度为O(n); -- 平均情况:随机删除,平均需要(n-1)/2,对应的时间复杂度为O(n); - -**线性表删除算法的平均时间复杂度为O(n);** - -#### 按值查找(顺序查找) - -在顺序表L中查找第一个元素值等于e的元素,并返回位序 - -```cpp -/* - * @Description: 顺序表的按值查找(顺序查找) - * @Version: Beta1.0 - * @Author: 【B站&公众号】Rong姐姐好可爱 - * @Date: 2020-02-23 07:48:26 - * @LastEditors: 【B站&公众号】Rong姐姐好可爱 - * @LastEditTime: 2020-02-23 07:48:26 - */ -int LocateElem(SqList L,ElemType e){ - int i; - // 循环判断 - for(i=0;i 队列的顺序实现是指分配一块连续的存储单元用来存放队列中的元素,并且附加两个指针。 diff --git a/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md b/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md index cad3de1..c1caa3d 100644 --- a/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md +++ b/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md @@ -1,4 +1,10 @@ - +--- +title: 队列的链式存储结构 +#description: +permalink: /manuscripts/ds/queue-chained-storage.html +head: +- [meta, { name: 数据结构 , content: 队列的链式存储结构 }] +--- # 队列的链式存储结构 `链队列`:和顺序队列一样,基于队列的链式表示叫做`链队列`,实际上为:**一个同时带有队头指针和队尾指针的单链表** diff --git a/docs/manuscripts/ds/栈和队列/7.栈VS队列补充.md b/docs/manuscripts/ds/栈和队列/7.栈VS队列补充.md index 90bda70..f6d37e5 100644 --- a/docs/manuscripts/ds/栈和队列/7.栈VS队列补充.md +++ b/docs/manuscripts/ds/栈和队列/7.栈VS队列补充.md @@ -1,3 +1,10 @@ +--- +title: 栈VS队列补充 +#description: +permalink: /manuscripts/ds/stack-vs-queue.html +head: + - [meta, { name: 数据结构 , content: 栈VS队列补充 }] +--- # 栈VS队列补充 @@ -11,7 +18,7 @@ root(栈VS队列补充) 矩阵的压缩存储 ``` -### 栈的应用 +## 栈的应用 - 括号匹配 - 表达式求值 @@ -111,7 +118,7 @@ int Fibonacci(n){ **递归次数过多容易造成栈溢出,效率不高的主要原因是递归调用过程中包含很多重复的计算** -### 队列的应用 +## 队列的应用 - 层次遍历 @@ -126,7 +133,7 @@ int Fibonacci(n){ 其实,队列在计算机系统的中应用, 在看完操作系统那本书后,就会很好理解,建议学到这里,也去翻翻操作系统,汤晓丹那本很经典哟... -# 特殊矩阵的压缩存储 +## 特殊矩阵的压缩存储 > 这部分知识我个人觉得以了解为主,复习、学习的时候还是要以前面的部分为主! diff --git a/docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md b/docs/manuscripts/ds/线性表/1.基础概念和操作.md similarity index 92% rename from docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md rename to docs/manuscripts/ds/线性表/1.基础概念和操作.md index cbf8e1b..b037cab 100644 --- a/docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md +++ b/docs/manuscripts/ds/线性表/1.基础概念和操作.md @@ -1,3 +1,11 @@ +--- +title: 基础概念 +#description: +permalink: /manuscripts/ds/linear-table-basic-concepts.html +head: + - [meta, { name: 数据结构 , content: 线性表的基础概念和操作 }] +--- + # 线性表的基础概念和操作 > 强调线性表是一种逻辑结构,不是存储结构 @@ -13,7 +21,7 @@ root(数据结构三要素) 数据的运算 ``` -### 定义 +## 定义 线性表是具有相同数据类型的n(n≥0)个数据元素的有限序列。一般表示: @@ -37,7 +45,7 @@ L=(a1,a2,a3......an) 其中n可以 > Tips: **线性表是一种逻辑结构**,表示元素之间一对一的相邻关系。**顺序表和链表则指的是存储结构** -### 基本操作 +## 基本操作 - `InitList(&L)`: **初始化表**。构造空的线性表 - `Length(L)`:**获取表的长度**。返回线性表L的长度,即表中的数据元素个数 diff --git a/docs/manuscripts/ds/线性表/2.顺序表示.md b/docs/manuscripts/ds/线性表/2.顺序表示.md new file mode 100644 index 0000000..e69de29 diff --git a/docs/manuscripts/ds/linear-table/3.chained_representation.md b/docs/manuscripts/ds/线性表/3.链式表示.md similarity index 98% rename from docs/manuscripts/ds/linear-table/3.chained_representation.md rename to docs/manuscripts/ds/线性表/3.链式表示.md index 43cc0e7..b65a422 100644 --- a/docs/manuscripts/ds/linear-table/3.chained_representation.md +++ b/docs/manuscripts/ds/线性表/3.链式表示.md @@ -1,3 +1,10 @@ +--- +title: 链式表示 +#description: +permalink: /manuscripts/ds/linear-table-chained-representation.html +head: + - [meta, { name: 数据结构 , content: 线性表的链式表示 }] +--- # 链式表示 ```mindmap diff --git a/docs/manuscripts/ds/linear-table/4.总结.md b/docs/manuscripts/ds/线性表/4.总结.md similarity index 96% rename from docs/manuscripts/ds/linear-table/4.总结.md rename to docs/manuscripts/ds/线性表/4.总结.md index 0ce0b3b..0c54846 100644 --- a/docs/manuscripts/ds/linear-table/4.总结.md +++ b/docs/manuscripts/ds/线性表/4.总结.md @@ -1,3 +1,11 @@ +--- +title: 链式表示 +#description: +permalink: /manuscripts/ds/linear-table-summary.html +head: + - [meta, { name: 数据结构 , content: 线性表总结 }] +--- + # 线性表总结 ```mindmap diff --git a/docs/manuscripts/ds/linear-table/readme.md b/docs/manuscripts/ds/线性表/readme.md similarity index 100% rename from docs/manuscripts/ds/linear-table/readme.md rename to docs/manuscripts/ds/线性表/readme.md diff --git a/docs/manuscripts/ds/linear-table/线性表_水印.png b/docs/manuscripts/ds/线性表/线性表_水印.png similarity index 100% rename from docs/manuscripts/ds/linear-table/线性表_水印.png rename to docs/manuscripts/ds/线性表/线性表_水印.png diff --git a/docs/readme.md b/docs/readme.md index 0fc0d7b..4000ffe 100644 --- a/docs/readme.md +++ b/docs/readme.md @@ -2,7 +2,7 @@ home: true title: 首页 heroText: 计算机应试全家桶 -tagline: 保持终身学习,读研or考研,做适合自己的选择 +tagline: 保持终身学习,读研or考研,做适合自己的选择! actions: - text: 快速开始→ link: /quick-start.md