177
README.md
@@ -1,22 +1,4 @@
|
||||
|
||||
<!-- <img src="https://cdn.142vip.cn/article-notes/img/image-20200605224832237.png"> -->
|
||||
<p align="center">
|
||||
<img src="https://static01.imgkr.com/temp/f0108d7c178b4ce196e43ebec14fbf23.png">
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="#gzh" target="_blank"><img src="https://img.shields.io/badge/WeChat-公众号-5wd.svg"></a>
|
||||
<a href="#wechat" target="_blank"><img src="https://img.shields.io/badge/WeChat-微信-yellow.svg"></a>
|
||||
<a href="https://space.bilibili.com/350937042" target="_blank"><img src="https://img.shields.io/badge/Bilibili-哔哩哔哩-green.svg"></a>
|
||||
<a href="https://142vip.cn" target="_blank"><img src="https://img.shields.io/badge/142vip-网站-orange.svg"></a>
|
||||
<a href="https://blog.142vip.cn" target="_blank"><img src="https://img.shields.io/badge/blog-博客-blue.svg"></a>
|
||||
<a href="https://github.com/mmdapl" target="_blank"><img src="https://img.shields.io/badge/Github-Github-9ac.svg"></a>
|
||||
<a href="https://gitee.com/mmdapl" target="_blank"><img src="https://img.shields.io/badge/Gitee-码云-4ed.svg"></a>
|
||||
<a href="https://blog.csdn.net/Mmdapl" target="_blank"><img src="https://img.shields.io/badge/csdn-CSDN-8ea.svg"></a>
|
||||
<a href="https://juejin.im/user/448256476724807" target="_blank"><img src="https://img.shields.io/badge/JueJin-掘金-75c.svg"></a>
|
||||
</p>
|
||||
|
||||
<!-- [Github文档](https://mmdapl.github.io/408CSFamily/) | [Gitee文档(国内访问快)]() -->
|
||||
## 写最前面
|
||||
> `408CSFamily` 我的理解是:408计算机专业课”全家桶“,而408相信考研er都知道计算机考研专业课代码;在最新的高校计算机研究生招考中,已经越来越多的学校改考408。可见408所涉及到的专业课举足轻重的地位;不论是在考研或者找工作,我相信408的专业基础必定是难以避免的,所以话不多说、形势复杂,唯一能做的就是不停的学习、巩固基础知识,加油!
|
||||
>
|
||||
@@ -28,23 +10,21 @@
|
||||
2. 建议结合思维导图进行学习
|
||||
|
||||
|
||||
## 在线阅读
|
||||
### 在线浏览
|
||||
|
||||
- 稳定版: <https://408.142vip.cn>
|
||||
|
||||
https://408.142vip.cn
|
||||
|
||||
网站无法访问时,建议通过科学上网访问备用网络
|
||||
|
||||
- Github: https://142vip.github.io/408CSFamily
|
||||
- Netlify: https://408-family.netlify.app
|
||||
- Vercel: https://408-family.vercel.app
|
||||
- Github: <https://142vip.github.io/408CSFamily>
|
||||
- Netlify: <https://408-family.netlify.app>
|
||||
- Vercel: <https://408-family.vercel.app>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 思维导图【MD文档版本】
|
||||
### 思维导图【MD文档版本】
|
||||
|
||||
> 主要是关键知识,更新优化中...
|
||||
|
||||
@@ -116,16 +96,16 @@ https://408.142vip.cn
|
||||
- [零碎知识补充](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485549&idx=2&sn=5282cd006b6c33e4bfe992298602e053&chksm=fcdfb1e1cba838f743a335bad530cf415eef57a417b807257d8ed6983047c2d57d5552b34cb0&token=1697862929&lang=zh_CN#rd)
|
||||
|
||||
|
||||
#### [栈和队列](/数据结构/栈和队列/Readme.md)
|
||||
#### [栈和队列](Readme.md)
|
||||
|
||||
- [栈的基本概念和基本操作](/数据结构/栈和队列/1.栈的基本概念和基本操作.md)
|
||||
- [栈的顺序存储结构](/数据结构/栈和队列/2.栈的顺序存储结构.md)
|
||||
- [栈的链式存储结构](/数据结构/栈和队列/3.栈链式存储结构.md)
|
||||
- [队列的基本概念和基础操作](/数据结构/栈和队列/4.队列的基本概念和基础操作.md)
|
||||
- [队列的顺序存储](/数据结构/栈和队列/5.队列的顺序存储结构.md)
|
||||
- [队列的链式存储](/数据结构/栈和队列/6.队列的链式存储结构.md)
|
||||
- [栈和队列的应用](/数据结构/栈和队列/栈和队列的应用.md)
|
||||
- [特殊矩阵的压缩存储](/数据结构/栈和队列/8.特殊矩阵的压缩存储.md)
|
||||
- [栈的基本概念和基本操作](1.栈的基本概念和基本操作.md)
|
||||
- [栈的顺序存储结构](2.栈的顺序存储结构.md)
|
||||
- [栈的链式存储结构](3.栈链式存储结构.md)
|
||||
- [队列的基本概念和基础操作](4.队列的基本概念和基础操作.md)
|
||||
- [队列的顺序存储](5.队列的顺序存储结构.md)
|
||||
- [队列的链式存储](6.队列的链式存储结构.md)
|
||||
- [栈和队列的应用](栈和队列的应用.md)
|
||||
- [特殊矩阵的压缩存储](8.特殊矩阵的压缩存储.md)
|
||||
|
||||
|
||||
#### 树与二叉树
|
||||
@@ -539,69 +519,102 @@ https://408.142vip.cn
|
||||
- 有安全相关工作背景者优先,有大型网站架构经验者优先,具备全栈/跨端开发能力者优先。 -->
|
||||
|
||||
|
||||
|
||||
## 赞赏支持
|
||||
|
||||
**赞赏过的一定要微信跟我说呀!!!!!!**
|
||||
## 赞赏列表
|
||||
|
||||
|
||||
<a name="wechat"></a>
|
||||
|
||||
|
||||
<div align="left">
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/wechat_donate.png" width="300" height="300" style="border-radius:5px;" />
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
## 联系我
|
||||
|
||||
|
||||
有任何问题或建议,欢迎微信`骚扰`,商务合作请备注!
|
||||
|
||||
<div align="left">
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/wechat_code.jpg" width="300" height="300" style="border-radius:5px;"/>
|
||||
</div>
|
||||
|
||||
|
||||
## 鸣谢
|
||||
|
||||
|
||||
以下排名不分先后!
|
||||
以下排名不分先后! [传送门→]() **赞赏过的一定要微信跟我说呀!!!!!!**
|
||||
|
||||
|
||||
<div>
|
||||
<a href="https://github.com/ChiefPing" target="_blank">
|
||||
<a href="https://github.com/ChiefPing" target="_blank" style="margin: 5px">
|
||||
<img src="https://avatars2.githubusercontent.com/u/34122068?s=460&v=4" width="50px" style="brder-radius:5px;"/>
|
||||
</a> <a href="https://github.com/xiaoliuxin" target="_blank">
|
||||
</a>
|
||||
<a href="https://github.com/xiaoliuxin" target="_blank" style="margin: 5px">
|
||||
<img src="https://avatars2.githubusercontent.com/u/60652527?s=460&v=4" style="border-radius:5px;" width="50px"/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
## 赞助列表
|
||||
|
||||
以下排名不分先后!
|
||||
## 赞助商
|
||||
|
||||
**以下排名不分先后! 还木有收到赞助,哈哈哈,先留坑**
|
||||
|
||||
|
||||
|
||||
|
||||
## 联系作者
|
||||
|
||||
若系列文章对你有所帮助,欢迎订阅公众号或微信”骚扰“,获取更多内容。**商务合作请备注来意**
|
||||
|
||||
<div style="text-align: center">
|
||||
<div align="center" >
|
||||
<table style="border:none;cell-padding:0; cell-spacing:0;border-collapse:collapse;" border="0">
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/media/fairy-sister-450x450.jpg"
|
||||
width="250px"
|
||||
title="欢迎关注公众号:Rong姐姐好可爱" alt="关注公众号"/>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/media/chu-fan-443-650x650.jpg"
|
||||
width="250px"
|
||||
title="欢迎添加微信:chufan443 " alt="联系作者"/>
|
||||
</table>
|
||||
</div>
|
||||
<div style="text-align: center;padding: 10px" align="center">
|
||||
<a
|
||||
href="https://github.com/mmdapl"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转Github主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/github.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://gitee.com/Mmdapl"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转码云主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/gitee.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://juejin.im/user/448256476724807"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转掘金主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/juejin.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://space.bilibili.com/350937042"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转B站主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/bilibili.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://blog.csdn.net/Mmdapl"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转CSDN博客主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/csdn.svg"
|
||||
title="点击跳转CSDN博客主页"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
交流/加群/互看朋友圈
|
||||
当然:**聊天 /提问 /建议 /提需求** 可以在本公众号直接**私信**,后台可以看到,有时间即会回复,偶尔的延迟和疏漏还请小伙伴们谅解,蟹蟹。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 公众号
|
||||
|
||||
- 相逢不用忙归去,明日黄花蝶也愁....
|
||||
|
||||
- 若系列文章对你有所帮助,不如来公众号交个朋友吧.
|
||||
|
||||
|
||||
<a name="gzh"></a>
|
||||
|
||||
|
||||
<p>
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/gongzhonghao.jpg" style="border-radius:10px;">
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
43
code/ds/BinaryInsertSort.cpp
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @Description: 折半插入算法【伪代码】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-04-15 18:27:59
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-27 12:19:13
|
||||
*/
|
||||
|
||||
void BinaryInsertSort(ElemType Arr[],int n){
|
||||
int i,j,lowIndex,heightIndex,midIndex;
|
||||
|
||||
for(i=2;j<=n;i++){
|
||||
// 将待排序的元素暂存在Arr[0]上
|
||||
Arr[0]=Arr[i];
|
||||
|
||||
lowIndex=1; // 左侧子表 折半查找起始位置
|
||||
heightIndex=i-1; // 左侧子表 折半查找结束位置
|
||||
|
||||
while(lowIndex<=heightIndex){
|
||||
|
||||
// 左侧有序子表的中间位置角标
|
||||
midIndex=(lowIndex+heightIndex)/2;
|
||||
|
||||
if(Arr[midIndex].key>Arr[0].key){
|
||||
// 小于中间元素,插入位置在子表左侧
|
||||
heightIndex=mid-1
|
||||
}else{
|
||||
// 大于或者等于中间元素,插入位置在子表右侧
|
||||
lowIndex=midIndex+1;
|
||||
}
|
||||
}
|
||||
|
||||
// 跳出循环需要(lowIndex>heightIndex),说明待插入位置的角标在heightIndex之后,为 heightIndex+1,此时需要将(heightIndex,i)之间的所有元素后移
|
||||
|
||||
for(j=i-1;j>heightIndex;--j){
|
||||
Arr[j+1]=Arr[j]
|
||||
}
|
||||
|
||||
// 后移完成后,将元素Arr[0]赋值到位置(hightIndex+1)上
|
||||
Arr[heightIndex+1]=Arr[0]
|
||||
}
|
||||
}
|
||||
60
code/ds/BinaryInsertSort.js
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* @Description: 折半插入排序【JavaScript版本】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-27 12:35:17
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-27 12:50:00
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 折半插入排序
|
||||
* @param {Array} arr 待排序数组
|
||||
* @param {int} len 数组长度
|
||||
*/
|
||||
function binaryInsertSort(arr,len){
|
||||
|
||||
// 数组长度校验【非必须】
|
||||
|
||||
len=arr.length===len?len:arr.length
|
||||
|
||||
|
||||
for(let i=1;i<len;i++){
|
||||
|
||||
const temp=arr[i];
|
||||
let lowIndex=0,highIndex=i-1;
|
||||
|
||||
while(lowIndex<=highIndex){
|
||||
// 注意:取整,javascript这里取整,会出现空指针
|
||||
const mid=parseInt((lowIndex+highIndex)/2);
|
||||
|
||||
if(arr[mid]<=temp){
|
||||
// 右侧
|
||||
lowIndex=mid+1
|
||||
}else{
|
||||
// 左侧
|
||||
highIndex=mid-1
|
||||
}
|
||||
}
|
||||
// 元素后移
|
||||
|
||||
for(let j=i-1;j>highIndex;--j){
|
||||
arr[j+1]=arr[j]
|
||||
}
|
||||
arr[highIndex+1]=temp;
|
||||
|
||||
}
|
||||
|
||||
// 返回经过折半插入排序处理的有序数组
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dealArr=[5,2,7,3,18,8,12,1]
|
||||
console.log('插入排序前:',dealArr)
|
||||
const sortResult=binaryInsertSort(dealArr,7)
|
||||
|
||||
console.log('插入排序后:',sortResult)
|
||||
|
||||
59
code/ds/BubbleSort.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/*
|
||||
* @Description: 冒泡排序
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-31 08:24:18
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-04-06 07:26:15
|
||||
*/
|
||||
|
||||
|
||||
void BubbleSwapSort(ElemType A[], int n){
|
||||
|
||||
for(i=0;i<n-1;i++){
|
||||
|
||||
|
||||
// 当前趟次冒泡,是否发生了元素交换,初始化为false
|
||||
bool flag=false;
|
||||
|
||||
for(j=n-1;j>i;j--){
|
||||
if(A[j-1].key>A[j].key){
|
||||
|
||||
// 将两个元素A[j-1]、A[j]进行交换,有多种方法
|
||||
swap(A[j-1],A[j])
|
||||
// 确认已发生交换
|
||||
flag=true
|
||||
}
|
||||
}
|
||||
|
||||
// 本趟遍历后没有发生交换,说明表已经有序
|
||||
if(flag==false){
|
||||
return ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 加减法实现两个元素值互换
|
||||
*
|
||||
*/
|
||||
void swap(int a, int b){
|
||||
// 此时a为两值的和
|
||||
a=a+b;
|
||||
// 此时b的值为a
|
||||
b=a-b
|
||||
// 如何实现让a的值为b呢??此时a的值为b
|
||||
a=a-b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 临时变量实现两个元素值的互换
|
||||
*
|
||||
*/
|
||||
void swap(int a,int b){
|
||||
int temp;
|
||||
temp=a;
|
||||
a=b;
|
||||
b=temp
|
||||
}
|
||||
|
||||
61
code/ds/BubbleSort.js
Normal file
@@ -0,0 +1,61 @@
|
||||
/*
|
||||
* @Description: 冒泡排序【JavaScript版本】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-04-06 07:26:59
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-04-06 08:01:19
|
||||
*/
|
||||
|
||||
|
||||
|
||||
function BubbleSort (arr, len) {
|
||||
// 校正数组的长度
|
||||
len = arr.length == len ? len : arr.length
|
||||
|
||||
// 冒泡排序,让数组arr有序
|
||||
for (let i = 0; i < len - 1; i++) {
|
||||
|
||||
let isSorted = false;
|
||||
|
||||
// len个数组,进行len-1趟,即:一趟冒泡
|
||||
for (let j = len - 1; j > i; j--) {
|
||||
// 注意:这里的for循环倒序是有讲究的,想象一下泡泡不都是网上升的么....
|
||||
if (arr[j - 1] > arr[j]) {
|
||||
// 交换元素,始终让最小的元素往上走(冒泡)
|
||||
const temp = arr[j - 1];
|
||||
arr[j - 1] = arr[j];
|
||||
arr[j] = temp
|
||||
|
||||
// 需要冒泡
|
||||
isSorted = true
|
||||
}
|
||||
}
|
||||
// 第一趟比较后,如果本身序列是有序的,就直接跳出循环
|
||||
if (isSorted === false) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 加减法交换元素的值
|
||||
* 注意:JavaScript中使用需要考虑到作用域的问题
|
||||
* @param {int} a
|
||||
* @param {int} b
|
||||
*/
|
||||
function swap (a, b) {
|
||||
a = a + b;
|
||||
b = a - b;
|
||||
a = a - b;
|
||||
}
|
||||
|
||||
|
||||
const initArr = [1, 5, 8, 3, 2, 9, 16]
|
||||
console.log(`冒泡排序前:${initArr}`)
|
||||
const sortedArr = BubbleSort(initArr, 7);
|
||||
console.log(`冒泡排序后:${sortedArr}`)
|
||||
155
code/ds/LinkList.cpp
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* @Description: 单链表
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-05 21:30:58
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @Description: 单链表头插法
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 23:39:16
|
||||
*/
|
||||
LinkList CreateListWithStartNode(LinkList &L){
|
||||
|
||||
LNode *s;
|
||||
int x;
|
||||
L=(LinkList)malloc(sizeof(LNode)); // 创建头结点L
|
||||
L->next=NULL; // 初始化空链表
|
||||
|
||||
// 控制台输入值
|
||||
scanf("%d",&x);
|
||||
|
||||
// 输入9999 表示结束
|
||||
while(x!==9999){
|
||||
// 开辟新结点存储空间
|
||||
s=(LNode*)malloc(sizeof(LNode));
|
||||
// 结点数据域赋值
|
||||
s->data=x;
|
||||
// 修改指针,新结点插入表中【注意:L->next为头结点的指针域】
|
||||
s->next=L->next;
|
||||
L->next=s;
|
||||
scanf("%d",&x);
|
||||
}
|
||||
|
||||
// 返回单链表
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @Description: 单链表尾插法
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 23:39:16
|
||||
*/
|
||||
LinkList CreateListWithEndNode(LinkList &L){
|
||||
|
||||
|
||||
int x; // 输入结点值
|
||||
L=(LinkList)malloc(sizeof(LNode));
|
||||
LNode *s; // 新结点s
|
||||
LNode *r=L; // r为尾指针
|
||||
|
||||
// 控制台输入值
|
||||
scanf("%d",&x);
|
||||
|
||||
while(x!==9999){
|
||||
// 开辟新结点存储空间
|
||||
s=(LNode *)malloc(sizeof(LNode));
|
||||
|
||||
// 新结点s的数据域赋值为x
|
||||
s->data=x;
|
||||
// 单链表L的尾指针指向新的结点s
|
||||
r->next=s;
|
||||
|
||||
// 指针r指向新的表尾结点
|
||||
r=s;
|
||||
|
||||
scanf("%d",&x);
|
||||
}
|
||||
|
||||
// 表尾指针置空【重要】
|
||||
r->next=NULL;
|
||||
|
||||
// 返回单链表
|
||||
return L;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @Description: 单链表按序号查找
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 23:39:16
|
||||
*/
|
||||
LNode *GetElem(LinkList L,int i){
|
||||
int j=1; // 查询计数,初始为1
|
||||
LNode *p=L->next; // 单链表头结点指针赋值给指针p
|
||||
|
||||
|
||||
// 第0个元素,则指向头结点,返回头结点
|
||||
if(i==0){
|
||||
// 头结点包含数据域和指针域
|
||||
return L;
|
||||
}
|
||||
|
||||
// 不等于0,却小于1,则i为负数无效,直接返回NULL,查询结果空;
|
||||
if(i<1){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// p存在且计数没有走到初始i的位置
|
||||
while(p&&j<i){
|
||||
|
||||
// 指针后移
|
||||
p=p->next;
|
||||
|
||||
// 计数标记+1
|
||||
j++;
|
||||
}
|
||||
|
||||
// 注意: 当p不存在时, 跳出循环,p=NULL; 当p存在但是j大于等于i,跳出循环,返回查找的结果,返回p
|
||||
// 从跳出循环上来分析,p要么存在即:找到的结点元素,要么为空即NULL
|
||||
|
||||
// 跳出循环,返回第i个结点的指针
|
||||
return p;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* @Description: 单链表按值查找
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 23:39:16
|
||||
*/
|
||||
LNode *LocateElem(LinkList L,ElemType e){
|
||||
|
||||
// 指针【哨兵】
|
||||
LNode *p=L->next;
|
||||
// 从第1个结点开始查找数据域(data)为e的结点
|
||||
while(p!=NULL&&p->data!=e){
|
||||
// 无法匹配,指针后移
|
||||
p=p->next;
|
||||
}
|
||||
|
||||
// 注意:p为NULL的时候,说明单链表已经遍历的尾结点了,跳出循环,没有找到目标结点;
|
||||
|
||||
// 查找到第1个匹配的结点,跳出循环,返回结点指针
|
||||
return p;
|
||||
//
|
||||
}
|
||||
|
||||
91
code/ds/LinkStack.cpp
Normal file
@@ -0,0 +1,91 @@
|
||||
/*
|
||||
* @Description: 链栈的相关操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-01-15 9:19:56
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-13 12:27:36
|
||||
*/
|
||||
|
||||
// 链栈类型定义【基础】
|
||||
typedef struct LinkNode{
|
||||
ElemType data; // 栈元素结点数据域
|
||||
struct LinkNode *next; // 栈元素结点指针域
|
||||
} *LinkStack;
|
||||
|
||||
// 更为详细的定义
|
||||
|
||||
typedef struct StackNode
|
||||
{
|
||||
int data;//结点数据域
|
||||
struct StackNode* next;//结点指针域
|
||||
}StackNode,* Linktop;
|
||||
|
||||
//链栈的数据结构
|
||||
typedef struct LinkStack
|
||||
{
|
||||
Linktop top; //栈顶结点,定义了一个指向上个结构体的指针
|
||||
int count;//元素个数
|
||||
}LinkStack;
|
||||
|
||||
|
||||
/*
|
||||
* @Description: 基于单链表链栈的进栈操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 07:36:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 11:39:16
|
||||
*/
|
||||
bool linkStackPushNode(LinkStack* linkStack,int e){
|
||||
|
||||
// 判断链栈是否存在
|
||||
if (!linkStack){
|
||||
//链栈不存在,无法进栈操作,返回false
|
||||
return false;
|
||||
}
|
||||
// 开辟栈结点元素内存控件
|
||||
StackNode* node = (StackNode*)malloc(sizeof(StackNode));
|
||||
// 新结点指针域指向链表,即栈顶指针位置,元素加入链表
|
||||
node->next = linkStack->top;
|
||||
// 新结点数据域赋值
|
||||
node->data = e;
|
||||
// 元素进栈,移动栈顶指针,指向新入栈的元素
|
||||
linkStack->top = node;
|
||||
// 链栈元素总数+1
|
||||
linkStack->count++;
|
||||
//链栈入栈成功,返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* @Description: 基于单链表链栈的出栈操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 23:39:16
|
||||
*/
|
||||
bool linkStackPopNode(LinkStack* linkStack,int *e){
|
||||
// 判断链栈是否存在及是否为空
|
||||
if (!linkStack || linkStack->count==0){
|
||||
//出栈失败,返回false
|
||||
return false;
|
||||
}
|
||||
// 获取栈顶元素结点
|
||||
StackNode* node = stack->top;
|
||||
|
||||
// 结点元素数据域赋值给变量e
|
||||
*e = linkStack->data;
|
||||
// 移动栈顶指向,栈顶指针指向待出栈结点的后继结点
|
||||
linkStack->top = node->next;
|
||||
// 变量e已被赋值,释放链栈出栈元素的内存控件
|
||||
free(node);
|
||||
// 链栈元素个数-1
|
||||
linkStack->count--;
|
||||
// 出栈成功,返回true.
|
||||
return true;
|
||||
}
|
||||
56
code/ds/LoopQueue.cpp
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* @Description: 循环队列操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2019-09-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 23:52:10
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// 队列最大存储元素个数
|
||||
#define MaxSize 50
|
||||
|
||||
// 结构体定义
|
||||
typedef struct {
|
||||
// 存放队列元素
|
||||
ElemType data[MaxSize];
|
||||
// 队头指针和队尾指针
|
||||
int front,rear;
|
||||
} SqQueue;
|
||||
|
||||
|
||||
|
||||
|
||||
// 入队算法
|
||||
// 尾插法:Q.data[Q.rear]=x;Q.rear=(Q.rear+1)%Maxsize;Q.tag=1
|
||||
// 队空条件:Q.front== Q.rear且Q.tag==0
|
||||
int EnLoopQueue(SqQueue &Q, ElemType x){
|
||||
if(Q.front==Q.rear&&Q.tag==1){
|
||||
return 0;
|
||||
}
|
||||
Q.data[Q.rear]=x;
|
||||
Q.rear=(Q.rear+1)%MaxSize;
|
||||
Q.tag=1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 出队算法
|
||||
// 头结点删除:x=Q.data[Q.front];Q.front=(Q.front +1)%Maxsize;Q.tag=0
|
||||
// 队满条件:Q.front == Q.rear且Q.tag=1
|
||||
// 注意:当删除之后链表为空时,还需增加一步,将尾指针指向头结点
|
||||
int DeLoopQueue(SqQueue &Q, ElemType &x){
|
||||
if (Q.front==Q.rear&&Q.tag==0){
|
||||
return 0;
|
||||
}
|
||||
x=Q.data[Q.front];
|
||||
Q.front=(Q.front+1)%MaxSize;
|
||||
Q.tag=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
47
code/ds/QuickSort.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* @Description: 快速排序【伪代码】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-23 08:23:20
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-04-08 21:51:28
|
||||
*/
|
||||
|
||||
|
||||
void QuickSort(ElemType A[] , int low , int high){
|
||||
|
||||
// low > high 表角标越界,low=high 子表只有一个元素,不需要进行快排,已经有序
|
||||
if(low<high){
|
||||
|
||||
// 获取pivot基准,将当前待排序表分成左右两个子表
|
||||
int pivotKey = Partition(A,low,high)
|
||||
|
||||
// 对左边序列进行快排
|
||||
QuickSort(A,low,pivotKey-1)
|
||||
|
||||
// 对右边序列进行快排
|
||||
QuickSort(A,pivotKey+1,high)
|
||||
|
||||
}
|
||||
|
||||
return A
|
||||
|
||||
}
|
||||
|
||||
int Partition(ElemType A ,int low , int high){
|
||||
|
||||
ElemType pivot=A[low];
|
||||
|
||||
while(low<high){
|
||||
while(low<high && A[high]>=pivot) --high
|
||||
A[low]=A[high] // 比pivot小的都移到左表 注意--high 从后往前遍历
|
||||
|
||||
while(low<high && A[low]<=pivot ) ++low
|
||||
A[high]=A[low] // 比pivot大的都移到右表,注意++low 从前往后遍历
|
||||
}
|
||||
|
||||
// 此时low==high||low>high 跳出循环后即找到能将当前表一分为二的pivotKey值
|
||||
A[low]=pivot
|
||||
// 基准元素pivot对应最终的位置角标
|
||||
return low
|
||||
}
|
||||
70
code/ds/QuickSort.js
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* @Description: 快速排序【JavaScript版本】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-04-08 08:20:35
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-04-08 21:50:12
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 基于分治法思想,将数组进行快速排序
|
||||
* @param {Array} arr 待排序的数组
|
||||
* @param {int} low 数组低位角标 左指针
|
||||
* @param {int} high 数组高位角标 右指针
|
||||
* @returns
|
||||
*/
|
||||
function QuickSort(arr,low,high){
|
||||
|
||||
// low=high 说明只有一个元素,理解为有序,不做处理
|
||||
// low>high 说明左右指针已经重合,数组已经遍历完,需要跳出
|
||||
if(low<high){
|
||||
let pivotIndex=Partition(arr,low,high);
|
||||
// 处理左侧
|
||||
QuickSort(arr,low,pivotIndex-1);
|
||||
// 处理右侧
|
||||
QuickSort(arr,pivotIndex+1,high)
|
||||
}
|
||||
|
||||
// 经过快排处理的数组
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 寻找数组中的基准pivot,使得左侧元素全部小于等于pivot,右侧元素全部大于等于pivot
|
||||
* @param {Array} arr 分治思想处理后的数组
|
||||
* @param {int} low 数组低位角标 左指针
|
||||
* @param {int} high 数组高位角标 右指针
|
||||
* @returns
|
||||
*/
|
||||
function Partition(arr,low,high){
|
||||
|
||||
// 假设低位指针对应数组角标元素为基准pivot
|
||||
const pivot=arr[low];
|
||||
while(low<high){
|
||||
|
||||
// 从右往左直到比pivot小跳出循环
|
||||
while(low<high && arr[high]>= pivot ) --high;
|
||||
arr[low]=arr[high]
|
||||
|
||||
// 从左往右直到比pivot大跳出循环
|
||||
while(low<high && arr[low]<= pivot) ++low;
|
||||
arr[high]=arr[low]
|
||||
}
|
||||
|
||||
// 基准值移到最终的位置,此时左侧小于等于pivot 右侧大于等于pivot
|
||||
arr[low]=pivot
|
||||
|
||||
// 返回基准值的角标
|
||||
return low;
|
||||
}
|
||||
|
||||
|
||||
const initArr=[2,18,6,25,19,4,8,3,7];
|
||||
|
||||
console.log(`快速排序处理前:${initArr}`)
|
||||
const quickSortResult=QuickSort(initArr,0,8)
|
||||
console.log(`快速排序处理后:${quickSortResult}`)
|
||||
55
code/ds/ShellSort.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* @Description: 希尔排序【伪代码】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-04-13 13:05:22
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-27 17:03:41
|
||||
*/
|
||||
|
||||
void ShellSort(ElemType Arr[] , int n){
|
||||
// k是增量
|
||||
for(k=n/2;k>=1;k=k/2){
|
||||
|
||||
// 增量子表进行直接插入排序
|
||||
for(i=k+1;i<=n;++i){
|
||||
|
||||
if(Arr[i].key<Arr[i-k].key){
|
||||
|
||||
// 元素暂存
|
||||
Arr[0]=Arr[i];
|
||||
|
||||
for(j=i-k;j>0&&Arr[0].key<Arr[j].key;j-=k){
|
||||
// 记录后移,查找插入的位置
|
||||
Arr[j+k]=Arr[j]
|
||||
}
|
||||
// 插入
|
||||
Arr[j+k]=Arr[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ShellSortEnhance(ElemType Arr[] , int n){
|
||||
|
||||
// 采用k=n/2 幂函数 确认希尔排序的步长
|
||||
|
||||
for(k=n/2;k>=1;n/=2){
|
||||
|
||||
// // 步长为k,则对应分为k个组,分别对其进行 直接插入排序
|
||||
|
||||
for(i=1,i<=k;i++){
|
||||
|
||||
// 第一步: 对应组的元素找出来,组成新的待排序的数列
|
||||
// 第二步: 对待排序数列进行 直接插入排序
|
||||
|
||||
specialStraightInsertSort(ElemType Arr[], int n , int k , int i)
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
// 返回
|
||||
return Arr;
|
||||
}
|
||||
|
||||
130
code/ds/ShellSort.js
Normal file
@@ -0,0 +1,130 @@
|
||||
/*
|
||||
* @Description: 希尔排序
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-02-21 08:07:13
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-28 11:37:29
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* 数组的希尔排序
|
||||
* @param {Array} arr 待排序数组
|
||||
* @param {int} len 数组长度,可校验
|
||||
* @returns 返回已排序的数组,从小到大
|
||||
*/
|
||||
function shellSort (arr, len) {
|
||||
|
||||
// 校对数组长度
|
||||
len = arr.length === len ? len : arr.length
|
||||
|
||||
// 注意处理浮点【向上取整】 防止空指针
|
||||
for (let increment = Math.floor(len / 2); increment >= 1; increment = Math.floor(increment / 2)) {
|
||||
// 对每组数据,进行直接排序
|
||||
for (let groupIndex = 0; groupIndex < increment; ++groupIndex) {
|
||||
|
||||
specialStraightInsertSort(arr, len, increment, groupIndex)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return arr
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据希尔排序的步长对分组进行直接插入排序处理
|
||||
* @param {Array} arr 排序数组
|
||||
* @param {int} len 数组长度
|
||||
* @param {int} increment 增量步长
|
||||
* @param {int} groupIndex 分组,第几个分组
|
||||
*/
|
||||
function specialStraightInsertSort (arr, len, increment, groupIndex) {
|
||||
len = arr.length === len ? len : arr.length
|
||||
console.log(`数组长度:${len}----->当前步长:${increment}---->分组:${groupIndex}`)
|
||||
|
||||
for(let eleStartIndex=groupIndex+increment;eleStartIndex<len;eleStartIndex+=increment){
|
||||
// 此时eleStartIndex为直接插入排序的比较元素
|
||||
|
||||
|
||||
// 直接插入排序中的哨兵元素【重要】
|
||||
const temp=arr[eleStartIndex]
|
||||
let j;
|
||||
// 向前比较 从小到大
|
||||
for(j=eleStartIndex-increment;j>=0&&arr[j]>temp;j-=increment){
|
||||
arr[j+increment]=arr[j]
|
||||
}
|
||||
arr[j+increment]=temp
|
||||
}
|
||||
|
||||
console.log('specialStraightInsertSort处理后:',arr)
|
||||
return arr
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 插入排序
|
||||
* @param{Array} arr 待排序的数组
|
||||
* @param{int} len 数组arr的长度,可以用arr.length()计算得到
|
||||
*/
|
||||
function straightInsertSort (arr, len) {
|
||||
// 重新确定数组长度
|
||||
len = arr.length === len ? len : arr.length;
|
||||
|
||||
// 从第二个元素开始循环,共len-1次
|
||||
for (let i = 1; i < len; i++) {
|
||||
|
||||
// 后面的额元素比前面的元素小,需要把前面大于哨兵元素有序序列,移动后面一位
|
||||
if (arr[i] < arr[i - 1]) {
|
||||
let j;
|
||||
// 哨兵元素
|
||||
const temp = arr[i];
|
||||
for (j = i - 1; arr[j] > temp; --j) {
|
||||
// 后移
|
||||
arr[j + 1] = arr[j]
|
||||
}
|
||||
// 跳出循环逻辑,出现arr[j] > arr[j-1]
|
||||
|
||||
// 哨兵即待排序的
|
||||
arr[j + 1] = temp
|
||||
}
|
||||
}
|
||||
|
||||
return arr
|
||||
|
||||
}
|
||||
|
||||
|
||||
const dealArr = [5, 8, 2, 16, 3, 9, 1]
|
||||
console.log('插入排序前:', dealArr)
|
||||
const sortResult = shellSort(dealArr, 7)
|
||||
console.log('插入排序后:', sortResult)
|
||||
|
||||
|
||||
/**
|
||||
* 简化的希尔排序
|
||||
* @param {Array} arr
|
||||
* @returns 返回已排序号的数组,从小到大
|
||||
*/
|
||||
function shellSortBetter (arr) {
|
||||
var len = arr.length;
|
||||
var increment = Math.floor(len / 2);
|
||||
while (increment != 0) {
|
||||
for (var i = increment; i < len; i++) {
|
||||
var temp = arr[i]
|
||||
for (var j = i - increment; j >= 0 && temp < arr[j]; j -= increment) {
|
||||
arr[j + increment] = arr[j]
|
||||
}
|
||||
arr[j + increment] = temp;
|
||||
}
|
||||
increment = Math.floor(increment / 2)
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
||||
console.log('简化shellSortBetter希尔排序前:', dealArr)
|
||||
const sortResultBetter = shellSortBetter(dealArr)
|
||||
console.log('简化shellSortBetter希尔排序后:', sortResultBetter)
|
||||
80
code/ds/SqList.cpp
Normal file
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* @Description: 顺序表的基础操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-02-23 07:48:26
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-02-23 07:48:26
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
// 基础结构体
|
||||
define MaxSize 50;
|
||||
typedef struct{
|
||||
ElemType data[MaxSize]; // ElemType 代表元素类型 int、string.....
|
||||
int length;
|
||||
}SqList
|
||||
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
81
code/ds/SqStack.cpp
Normal file
@@ -0,0 +1,81 @@
|
||||
/*
|
||||
* @Description: 顺序栈的相关操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-07 11:15:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-13 12:30:18
|
||||
*/
|
||||
|
||||
|
||||
// 定义栈中元素的最大个数
|
||||
# define MaxSize 50
|
||||
|
||||
// 结构体定义
|
||||
typedef struct{
|
||||
ElemType data[MaxSize]; // 存放栈中元素
|
||||
int top; // 栈顶指针
|
||||
}SqStack;
|
||||
|
||||
|
||||
// 初始化
|
||||
void InitStack(&S){
|
||||
// 栈顶指针-1
|
||||
s.top=-1;
|
||||
}
|
||||
|
||||
// 栈空判断
|
||||
bool StackEmpty(S){
|
||||
if(S.top==-1){
|
||||
// 栈空
|
||||
return true;
|
||||
}else{
|
||||
// 栈非空
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// 进栈
|
||||
bool Push(SqStack &S,ElemType x){
|
||||
if(S.top==MaxSize-1){
|
||||
// 栈满,返回false,元素无法进行进栈操作
|
||||
return false;
|
||||
}else{
|
||||
// 可进栈,栈顶指针+1,再元素入栈
|
||||
S.data[++S.top]=x;
|
||||
|
||||
// 入栈成功
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 出栈
|
||||
bool Pop(SqStack &S,ElemType &x){
|
||||
if(S.top==-1){
|
||||
// 栈空,无栈顶元素可出栈,返回false
|
||||
return false;
|
||||
}else{
|
||||
// 栈非空,先元素出栈,再进行指针-1
|
||||
x=S.data[S.top--];
|
||||
|
||||
// 出栈成功,返回true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// 读(获取)栈顶元素
|
||||
bool GetTop(SqStack S,ElemType &x){
|
||||
|
||||
if(S.top==-1){
|
||||
// 栈空,无栈顶元素,返回false
|
||||
return false;
|
||||
}else{
|
||||
|
||||
// 通过栈顶指针,获取栈顶元素,赋值给变量x
|
||||
x=S.data[S.top];
|
||||
|
||||
// 读取栈顶元素成功,返回true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
26
code/ds/StraightInsertSort.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* @Description: 直接插入排序【伪代码】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-25 08:07:23
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-26 07:29:00
|
||||
*/
|
||||
void straightInsertSort(ElemType A[], int n){
|
||||
int i,j;
|
||||
|
||||
// 依次将前面的第2到第n个元素插入到前面的有序序列
|
||||
for(i=2;i<=n;i++){
|
||||
if(A[i].key< A[i-1].key){
|
||||
// 哨兵元素
|
||||
A[0]=A[i];
|
||||
// 循环向后挪动
|
||||
for(j=i-1;A[0].key<A[j].key;--j){
|
||||
A[j+1]=A[j]
|
||||
}
|
||||
// 哨兵元素插入,注意这里为j+1,因为--j等循环完,先递减再使用,比预想靠后
|
||||
A[j+1]=A[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
49
code/ds/StraightInsertSort.js
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* @Description: 直接插入排序【JavaScript版本】
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-25 08:14:07
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-26 07:29:47
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 插入排序
|
||||
* @param{Array} arr 待排序的数组
|
||||
* @param{int} len 数组arr的长度,可以用arr.length()计算得到
|
||||
*/
|
||||
function straightInsertSort(arr,len){
|
||||
// 重新确定数组长度
|
||||
len=arr.length===len?len:arr.length;
|
||||
|
||||
// 从第二个元素开始循环,共len-1次
|
||||
for(let i=1;i<len;i++){
|
||||
|
||||
// 后面的额元素比前面的元素小,需要把前面大于哨兵元素有序序列,移动后面一位
|
||||
if(arr[i]<arr[i-1]){
|
||||
let j;
|
||||
// 哨兵元素
|
||||
const temp=arr[i];
|
||||
for(j=i-1; arr[j]>temp;--j){
|
||||
// 后移
|
||||
arr[j+1]=arr[j]
|
||||
}
|
||||
// 跳出循环逻辑,出现arr[j] > arr[j-1]
|
||||
|
||||
// 哨兵即待排序的
|
||||
arr[j+1]=temp
|
||||
}
|
||||
}
|
||||
|
||||
return arr
|
||||
|
||||
}
|
||||
|
||||
const dealArr=[5,2,7,3,18,8,12,1]
|
||||
console.log('插入排序前:',dealArr)
|
||||
const sortResult=straightInsertSort(dealArr,7)
|
||||
|
||||
console.log('插入排序后:',sortResult)
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
import themeConfig from "./config/theme.config";
|
||||
import pluginsConfig from "./config/plugins.config";
|
||||
|
||||
// 用于区分base路径,是否nginx代理
|
||||
const PROXY_DOMAIN=process.env.PROXY_DOMAIN||false
|
||||
|
||||
export default {
|
||||
title: "计算机应试全家桶",
|
||||
description: "磨刀不误砍柴工,读完硕士再打工",
|
||||
base: PROXY_DOMAIN ? "/408CSFamily/":"/",
|
||||
port: 4200,
|
||||
head: [
|
||||
[
|
||||
"link", {rel: "icon", href: "/408_favicon.ico"}
|
||||
],
|
||||
[
|
||||
// 百度统计
|
||||
'script', {}, `
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?3515cc46ae60747b778140f0e5e22dfe";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();`
|
||||
]
|
||||
],
|
||||
...themeConfig,
|
||||
...pluginsConfig
|
||||
}
|
||||
61
docs/.vuepress/config.ts
Normal file
@@ -0,0 +1,61 @@
|
||||
import pluginsConfig from "./config/plugins.config";
|
||||
import themeConfig from "./config/theme.config";
|
||||
import {defineUserConfig} from "vuepress";
|
||||
import {fileURLToPath} from 'node:url'
|
||||
import {path} from "@vuepress/utils";
|
||||
// @ts-ignore
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url))
|
||||
|
||||
// 用于区分base路径,是否nginx代理
|
||||
const PROXY_DOMAIN = process.env.PROXY_DOMAIN || false
|
||||
|
||||
|
||||
export default defineUserConfig({
|
||||
title: "计算机应试全家桶",
|
||||
description: "磨刀不误砍柴工,读完硕士再打工",
|
||||
base: PROXY_DOMAIN ? "/408CSFamily/" : "/",
|
||||
port: 4200,
|
||||
head: [
|
||||
["link", {rel: "icon", href: "/fight_favicon.ico"}],
|
||||
// vercel统计 相关配置
|
||||
['script', {type: 'text/javascript', src: '/_vercel/insights/script.js'}],
|
||||
[
|
||||
"link", {rel: "icon", href: "/408_favicon.ico"}
|
||||
],
|
||||
// 百度统计
|
||||
[
|
||||
'script', {}, `
|
||||
var _hmt = _hmt || [];
|
||||
(function() {
|
||||
var hm = document.createElement("script");
|
||||
hm.src = "https://hm.baidu.com/hm.js?3515cc46ae60747b778140f0e5e22dfe";
|
||||
var s = document.getElementsByTagName("script")[0];
|
||||
s.parentNode.insertBefore(hm, s);
|
||||
})();`
|
||||
]
|
||||
],
|
||||
markdown: {
|
||||
// todo 引入代码文件时的路径替换
|
||||
importCode: {
|
||||
handleImportPath: (str) => {
|
||||
if (str.includes('@code')) {
|
||||
return str.replace(/^@code/, path.resolve(__dirname, '../../code/'))
|
||||
}
|
||||
if (str.includes('~@')) {
|
||||
return str.replace(/^~@/, path.resolve(__dirname, '../../'))
|
||||
}
|
||||
return str
|
||||
},
|
||||
},
|
||||
// md doc formatter headerDepth
|
||||
headers: {
|
||||
level: [2, 3, 4]
|
||||
}
|
||||
},
|
||||
// 主题配置
|
||||
...themeConfig,
|
||||
// 插件配置
|
||||
...pluginsConfig,
|
||||
shouldPrefetch: false,
|
||||
})
|
||||
|
||||
83
docs/.vuepress/config/lang.config.ts
Normal file
@@ -0,0 +1,83 @@
|
||||
import {ThemeLocaleData} from "vuepress-theme-hope";
|
||||
|
||||
/**
|
||||
* 支持中文
|
||||
* 参考:https://theme-hope.vuejs.press/zh/config/i18n.html
|
||||
*/
|
||||
const localCN: ThemeLocaleData = {
|
||||
lang: "zh-CN",
|
||||
navbarLocales: {
|
||||
langName: "简体中文",
|
||||
selectLangAriaLabel: "选择语言",
|
||||
},
|
||||
metaLocales: {
|
||||
author: "作者",
|
||||
date: "写作日期",
|
||||
origin: "原创",
|
||||
views: "访问量",
|
||||
category: "分类",
|
||||
tag: "标签",
|
||||
readingTime: "阅读时间",
|
||||
words: "字数",
|
||||
toc: "标题大纲",
|
||||
prev: "上一页",
|
||||
next: "下一页",
|
||||
lastUpdated: "上次编辑于",
|
||||
contributors: "贡献者",
|
||||
editLink: "编辑此页",
|
||||
print: "打印",
|
||||
},
|
||||
|
||||
blogLocales: {
|
||||
article: "文章",
|
||||
articleList: "文章列表",
|
||||
category: "分类",
|
||||
tag: "标签",
|
||||
timeline: "时间轴",
|
||||
timelineTitle: "昨日不在",
|
||||
all: "全部",
|
||||
intro: "个人介绍",
|
||||
star: "收藏",
|
||||
},
|
||||
|
||||
paginationLocales: {
|
||||
prev: "上一页",
|
||||
next: "下一页",
|
||||
navigate: "跳转到",
|
||||
action: "前往",
|
||||
errorText: "请输入 1 到 $page 之前的页码!",
|
||||
},
|
||||
|
||||
outlookLocales: {
|
||||
themeColor: "主题色",
|
||||
darkmode: "外观",
|
||||
fullscreen: "全屏",
|
||||
},
|
||||
|
||||
encryptLocales: {
|
||||
iconLabel: "文章已加密",
|
||||
placeholder: "输入密码",
|
||||
remember: "记住密码",
|
||||
errorHint: "请输入正确的密码",
|
||||
},
|
||||
routeLocales: {
|
||||
skipToContent: "跳至主要內容",
|
||||
notFoundTitle: "访问的页面不存在,嘤嘤嘤",
|
||||
notFoundMsg: [
|
||||
"这里什么也没有",
|
||||
"我们是怎么来到这儿的?",
|
||||
"这 是 四 零 四 !",
|
||||
"看起来你访问了一个失效的链接",
|
||||
],
|
||||
back: "返回",
|
||||
home: "首页",
|
||||
openInNewWindow: "新窗口打开",
|
||||
},
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义语言,支持文案
|
||||
*/
|
||||
export const langConfig = {
|
||||
"/": localCN
|
||||
}
|
||||
72
docs/.vuepress/config/navbar.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
export const navbar = [
|
||||
{
|
||||
text: '首页',
|
||||
link: '/'
|
||||
},
|
||||
// {
|
||||
// text: "算法恶补",
|
||||
// children: [{
|
||||
// text: '习题狂刷',
|
||||
// link: '/manuscripts/algorithm/topic_practice'
|
||||
// }, {
|
||||
// text: '刷题笔记',
|
||||
// link: '/manuscripts/algorithm/algorithm_note'
|
||||
// }, {
|
||||
// text: '在线刷题',
|
||||
// children: [{
|
||||
// text: '杭电OJ', link: 'http://acm.hdu.edu.cn/'
|
||||
// },
|
||||
// {
|
||||
// text: '牛客网', link: 'https://www.nowcoder.com/'
|
||||
// }, {
|
||||
// text: 'LeetCode', link: 'https://leetcode-cn.com/'
|
||||
// }]
|
||||
// }]
|
||||
// },
|
||||
{
|
||||
text: "数据结构",
|
||||
link: "/manuscripts/ds"
|
||||
},
|
||||
{
|
||||
text: "操作系统",
|
||||
link: "/manuscripts/os"
|
||||
},
|
||||
{
|
||||
text: "计算机组成原理",
|
||||
link: "/manuscripts/ccp"
|
||||
},
|
||||
|
||||
{
|
||||
text: "计算机网络",
|
||||
link: "/manuscripts/cn"
|
||||
},
|
||||
{
|
||||
text: '其他资料',
|
||||
children: [{
|
||||
text: '考研相关',
|
||||
children: [{
|
||||
text: '111',
|
||||
link: '/333'
|
||||
}]
|
||||
}, {
|
||||
text: "思维导图",
|
||||
children: [{
|
||||
text: '数据结构',
|
||||
link: '/note-map/ds-map'
|
||||
}, {
|
||||
text: '操作系统',
|
||||
link: '/note-map/os-map'
|
||||
}, {
|
||||
text: '计算机组成原理',
|
||||
link: '/note-map/ccp-map'
|
||||
}, {
|
||||
text: '计算机网络',
|
||||
link: '/note-map/cn-map'
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
text: "大事记",
|
||||
link: "/big-event-history"
|
||||
},
|
||||
];
|
||||
@@ -1,71 +0,0 @@
|
||||
export default [
|
||||
{
|
||||
text: '主页',
|
||||
link: '/'
|
||||
},
|
||||
{
|
||||
text: "算法恶补",
|
||||
children: [{
|
||||
text: '习题狂刷',
|
||||
link: '/algorithm/topic_practice'
|
||||
}, {
|
||||
text: '刷题笔记',
|
||||
link: '/algorithm/algorithm_note'
|
||||
}, {
|
||||
text: '在线刷题',
|
||||
children: [{
|
||||
text: '杭电OJ', link: 'http://acm.hdu.edu.cn/'
|
||||
},
|
||||
{
|
||||
text: '牛客网', link: 'https://www.nowcoder.com/'
|
||||
}, {
|
||||
text: 'LeetCode', link: 'https://leetcode-cn.com/'
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
text: "数据结构",
|
||||
link: "/ds/basic_introduction"
|
||||
},
|
||||
{
|
||||
text: "操作系统",
|
||||
link: "/os/"
|
||||
},
|
||||
{
|
||||
text: "计算机组成原理",
|
||||
link: "/ccp/"
|
||||
},
|
||||
|
||||
{
|
||||
text: "计算机网络",
|
||||
link: "/cn/"
|
||||
}, {
|
||||
text: '其他资料',
|
||||
children: [{
|
||||
text: '考研相关',
|
||||
children: [{
|
||||
text: '111',
|
||||
link: '/333'
|
||||
}]
|
||||
}, {
|
||||
text: "思维导图",
|
||||
children: [{
|
||||
text: '数据结构',
|
||||
link: '/note-map/ds-map'
|
||||
}, {
|
||||
text: '操作系统',
|
||||
link: '/note-map/os-map'
|
||||
}, {
|
||||
text: '计算机组成原理',
|
||||
link: '/note-map/ccp-map'
|
||||
}, {
|
||||
text: '计算机网络',
|
||||
link: '/note-map/cn-map'
|
||||
}]
|
||||
}]
|
||||
},
|
||||
{
|
||||
text: "大事记",
|
||||
link: "/big-event-history"
|
||||
},
|
||||
];
|
||||
@@ -8,7 +8,7 @@ export default {
|
||||
// 为分类和标签添加索引
|
||||
customFields: [
|
||||
{
|
||||
getter: (page) => page.frontmatter.category,
|
||||
getter: (page:any) => page.frontmatter.category,
|
||||
formatter: "分类:$content",
|
||||
},
|
||||
{
|
||||
13
docs/.vuepress/config/sidebar.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import {algorithmSidebar} from "../../manuscripts/algorithm/algorithm.sidebar";
|
||||
import {dsSidebar} from "../../manuscripts/ds/ds.sidebar";
|
||||
import {cppSidebar} from "../../manuscripts/ccp/cpp.sidebar";
|
||||
import osSidebar from "../../manuscripts/os/os.sidebar";
|
||||
|
||||
export const sidebar = {
|
||||
"/ds": dsSidebar,
|
||||
"/ds/coding": algorithmSidebar,
|
||||
"/manuscripts/ds":dsSidebar,
|
||||
"/manuscripts/os":osSidebar,
|
||||
"/manuscripts/ccp":cppSidebar,
|
||||
"/manuscripts/cn":algorithmSidebar,
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
export default[
|
||||
]
|
||||
@@ -1,80 +0,0 @@
|
||||
export default [
|
||||
{
|
||||
text: '基础入门',
|
||||
link: "/ds/basic-introduction",
|
||||
collapsible: false,
|
||||
children: [{
|
||||
text: '1.1 基本概念',
|
||||
link: '/ds/basic-introduction/1.basic_concepts.md'
|
||||
}, {
|
||||
text: '1.2 数据结构三要素',
|
||||
link: '/ds/basic-introduction/2.three_elements_of_data_structure.md'
|
||||
}, {
|
||||
text: '1.3 算法和算法评价',
|
||||
link: '/ds/basic-introduction/3.algorithm_and_algorithm_evaluation.md'
|
||||
}],
|
||||
},
|
||||
{
|
||||
text: '线性表',
|
||||
collapsible: true,
|
||||
link: "/ds/linear-table",
|
||||
children: [{
|
||||
text: '2.1 基础概念和操作',
|
||||
link: '/ds/linear-table/1.basic_concept_and_operation.md'
|
||||
}, {
|
||||
text: '2.2 线性表的顺序表示',
|
||||
link: '/ds/linear-table/2.sequential_representation.md'
|
||||
}, {
|
||||
text: '2.3 基础概念和操作',
|
||||
link: '/ds/linear-table/3.chain_representation.md'
|
||||
}, {
|
||||
text: '2.4 基础概念和操作',
|
||||
link: '/ds/linear-table/4.double_linked_list.md'
|
||||
}, {
|
||||
text: '2.5 基础概念和操作',
|
||||
link: '/ds/linear-table/5.circular_list.md'
|
||||
}, {
|
||||
text: '2.6 基础概念和操作',
|
||||
link: '/ds/linear-table/6.static_linked_list.md'
|
||||
}, {
|
||||
text: '2.7 基础概念和操作',
|
||||
link: '/ds/linear-table/7.comparison_of_sequential_list_and_linked_list.md'
|
||||
}, {
|
||||
text: '2.8 存储结构的选取',
|
||||
link: '/ds/linear-table/8.selection_of_storage_structure.md'
|
||||
}, {
|
||||
text: '2.9 零碎知识补充',
|
||||
link: '/ds/linear-table/9.piecemeal_knowledge_supplement.md'
|
||||
}],
|
||||
},
|
||||
{
|
||||
text: "栈和队列",
|
||||
link: "/ds/栈和队列/",
|
||||
collapsible: true,
|
||||
children: [{
|
||||
text: '3.1 栈的基本概念和基本操作',
|
||||
link: '/ds/栈和队列/1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.2 栈的顺序存储结构',
|
||||
link: '/ds/栈和队列/2.栈的顺序存储结构.md'
|
||||
}, {
|
||||
text: '3.3 栈的基本概念和基本操作',
|
||||
link: '/ds/栈和队列/1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.4 栈的基本概念和基本操作',
|
||||
link: '/ds/栈和队列/1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.5 栈的基本概念和基本操作',
|
||||
link: '/ds/栈和队列/1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.6 栈的基本概念和基本操作',
|
||||
link: '/ds/栈和队列/1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.7 栈和队列的应用',
|
||||
link: '/ds/栈和队列/7.栈和队列的应用.md'
|
||||
}, {
|
||||
text: '3.8 特殊矩阵的压缩存储',
|
||||
link: '/ds/栈和队列/8.特殊矩阵的压缩存储.md'
|
||||
}]
|
||||
}
|
||||
]
|
||||
@@ -1,7 +0,0 @@
|
||||
import dsSidebar from "./ds.sidebar";
|
||||
import algorithmSidebar from "./algorithm.sidebar";
|
||||
|
||||
export default{
|
||||
"/ds": dsSidebar,
|
||||
"/ds/coding": algorithmSidebar
|
||||
};
|
||||
@@ -1,23 +1,26 @@
|
||||
import {hopeTheme} from "vuepress-theme-hope";
|
||||
import navbar from "./navbar";
|
||||
import sidebar from "./sidebar";
|
||||
import {FOOTER_HTML_INFO} from "./constant.config";
|
||||
import {hopeTheme} from "vuepress-theme-hope";
|
||||
import {langConfig} from "./lang.config";
|
||||
import {navbar} from "./navbar";
|
||||
import {sidebar} from "./sidebar";
|
||||
|
||||
/**
|
||||
* hope主题配置
|
||||
* 参考:https://theme-hope.vuejs.press/zh/config/
|
||||
*/
|
||||
|
||||
export default {
|
||||
theme: hopeTheme({
|
||||
locales: langConfig,
|
||||
darkmode:"toggle",
|
||||
// 支持全屏
|
||||
// fullscreen: true,
|
||||
// 纯净模式
|
||||
fullscreen: true,
|
||||
// 纯净模式s
|
||||
// pure: true,
|
||||
print: false, // 打印按钮
|
||||
hostname:'https://408.142vip.cn',
|
||||
author:{
|
||||
name:'ChuFan',
|
||||
name:'Chu Fan',
|
||||
email:'fairy_408@2925.com',
|
||||
url:'https://www.142vip.cn'
|
||||
},
|
||||
@@ -45,7 +48,7 @@ export default {
|
||||
intro:'',
|
||||
roundAvatar:true,
|
||||
timeline:"时间轴的顶部文字",
|
||||
articleInfo:"",
|
||||
// articleInfo:"",
|
||||
// sidebarDisplay:"always",
|
||||
medias:{
|
||||
"BiliBili": "https://space.bilibili.com/350937042?spm_id_from=333.1007.0.0"
|
||||
|
Before Width: | Height: | Size: 4.7 MiB |
|
Before Width: | Height: | Size: 70 KiB |
|
Before Width: | Height: | Size: 10 KiB |
@@ -1,175 +1,175 @@
|
||||
/* 此处自定义样式,对主题进行覆盖 */
|
||||
|
||||
//首页导航按钮
|
||||
.actions>a{
|
||||
margin-left: 5px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
// 隐藏 全文搜索
|
||||
.DocSearch-Logo{
|
||||
// display:none;不占位隐藏
|
||||
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 {
|
||||
// brand colors
|
||||
// --c-brand: #3eaf7c;
|
||||
// --c-brand-light: #4abf8a;
|
||||
|
||||
--c-brand: #4ce9ad;
|
||||
--c-brand-light: #42b983;
|
||||
|
||||
// background colors
|
||||
--c-bg: #ffffff;
|
||||
--c-bg-light: #f3f4f5;
|
||||
--c-bg-lighter: #eeeeee;
|
||||
--c-bg-navbar: var(--c-bg);
|
||||
--c-bg-sidebar: var(--c-bg);
|
||||
--c-bg-arrow: #cccccc;
|
||||
|
||||
// text colors
|
||||
--c-text: #2c3e50;
|
||||
--c-text-accent: var(--c-brand);
|
||||
--c-text-light: #3a5169;
|
||||
--c-text-lighter: #4e6e8e;
|
||||
--c-text-lightest: #6a8bad;
|
||||
--c-text-quote: #999999;
|
||||
|
||||
// border colors
|
||||
--c-border: #eaecef;
|
||||
--c-border-dark: #dfe2e5;
|
||||
|
||||
// custom container colors
|
||||
--c-tip: #42b983;
|
||||
--c-tip-bg: var(--c-bg-light);
|
||||
--c-tip-title: var(--c-text);
|
||||
--c-tip-text: var(--c-text);
|
||||
--c-tip-text-accent: var(--c-text-accent);
|
||||
--c-warning: #e7c000;
|
||||
--c-warning-bg: #fffae3;
|
||||
--c-warning-title: #ad9000;
|
||||
--c-warning-text: #746000;
|
||||
--c-warning-text-accent: var(--c-text);
|
||||
--c-danger: #cc0000;
|
||||
--c-danger-bg: #ffe0e0;
|
||||
--c-danger-title: #990000;
|
||||
--c-danger-text: #660000;
|
||||
--c-danger-text-accent: var(--c-text);
|
||||
--c-details-bg: #eeeeee;
|
||||
|
||||
// badge component colors
|
||||
--c-badge-tip: var(--c-tip);
|
||||
--c-badge-warning: var(--c-warning);
|
||||
--c-badge-danger: var(--c-danger);
|
||||
|
||||
// transition vars
|
||||
--t-color: 0.3s ease;
|
||||
--t-transform: 0.3s ease;
|
||||
|
||||
// code blocks vars
|
||||
--code-bg-color: #282c34;
|
||||
--code-hl-bg-color: rgba(0, 0, 0, 0.66);
|
||||
--code-ln-color: #9e9e9e;
|
||||
--code-ln-wrapper-width: 3.5rem;
|
||||
|
||||
// font vars
|
||||
--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
|
||||
Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
--font-family-code: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
|
||||
// layout vars
|
||||
--navbar-height: 3.6rem;
|
||||
--navbar-padding-v: 0.7rem;
|
||||
--navbar-padding-h: 1.5rem;
|
||||
--sidebar-width: 20rem;
|
||||
--sidebar-width-mobile: calc(var(--sidebar-width) * 0.82);
|
||||
--content-width: 740px;
|
||||
--homepage-width: 960px;
|
||||
}
|
||||
|
||||
// plugin-back-to-top
|
||||
.back-to-top {
|
||||
--back-to-top-color: var(--c-brand);
|
||||
--back-to-top-color-hover: var(--c-brand-light);
|
||||
}
|
||||
|
||||
// plugin-docsearch
|
||||
.DocSearch {
|
||||
--docsearch-primary-color: var(--c-brand);
|
||||
--docsearch-text-color: var(--c-text);
|
||||
--docsearch-highlight-color: var(--c-brand);
|
||||
--docsearch-muted-color: var(--c-text-quote);
|
||||
--docsearch-container-background: rgba(9, 10, 17, 0.8);
|
||||
--docsearch-modal-background: var(--c-bg-light);
|
||||
--docsearch-searchbox-background: var(--c-bg-lighter);
|
||||
--docsearch-searchbox-focus-background: var(--c-bg);
|
||||
--docsearch-searchbox-shadow: inset 0 0 0 2px var(--c-brand);
|
||||
--docsearch-hit-color: var(--c-text-light);
|
||||
--docsearch-hit-active-color: var(--c-bg);
|
||||
--docsearch-hit-background: var(--c-bg);
|
||||
--docsearch-hit-shadow: 0 1px 3px 0 var(--c-border-dark);
|
||||
--docsearch-footer-background: var(--c-bg);
|
||||
}
|
||||
|
||||
// plugin-external-link-icon
|
||||
.external-link-icon {
|
||||
--external-link-icon-color: var(--c-text-quote);
|
||||
}
|
||||
|
||||
// plugin-medium-zoom
|
||||
.medium-zoom-overlay {
|
||||
--medium-zoom-bg-color: var(--c-bg);
|
||||
}
|
||||
|
||||
// plugin-nprogress
|
||||
#nprogress {
|
||||
--nprogress-color: var(--c-brand);
|
||||
}
|
||||
|
||||
// plugin-pwa-popup
|
||||
.pwa-popup {
|
||||
--pwa-popup-text-color: var(--c-text);
|
||||
--pwa-popup-bg-color: var(--c-bg);
|
||||
--pwa-popup-border-color: var(--c-brand);
|
||||
--pwa-popup-shadow: 0 4px 16px var(--c-brand);
|
||||
--pwa-popup-btn-text-color: var(--c-bg);
|
||||
--pwa-popup-btn-bg-color: var(--c-brand);
|
||||
--pwa-popup-btn-hover-bg-color: var(--c-brand-light);
|
||||
}
|
||||
|
||||
// plugin-search
|
||||
.search-box {
|
||||
--search-bg-color: var(--c-bg);
|
||||
--search-accent-color: var(--c-brand);
|
||||
--search-text-color: var(--c-text);
|
||||
--search-border-color: var(--c-border);
|
||||
|
||||
--search-item-text-color: var(--c-text-lighter);
|
||||
--search-item-focus-bg-color: var(--c-bg-light);
|
||||
}
|
||||
///* 此处自定义样式,对主题进行覆盖 */
|
||||
//
|
||||
// //首页导航按钮
|
||||
//.actions>a{
|
||||
// margin-left: 5px;
|
||||
// margin-right: 5px;
|
||||
//}
|
||||
//// 隐藏 全文搜索
|
||||
//.DocSearch-Logo{
|
||||
// // display:none;不占位隐藏
|
||||
// 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 {
|
||||
// // brand colors
|
||||
// // --c-brand: #3eaf7c;
|
||||
// // --c-brand-light: #4abf8a;
|
||||
//
|
||||
// --c-brand: #4ce9ad;
|
||||
// --c-brand-light: #42b983;
|
||||
//
|
||||
// // background colors
|
||||
// --c-bg: #ffffff;
|
||||
// --c-bg-light: #f3f4f5;
|
||||
// --c-bg-lighter: #eeeeee;
|
||||
// --c-bg-navbar: var(--c-bg);
|
||||
// --c-bg-sidebar: var(--c-bg);
|
||||
// --c-bg-arrow: #cccccc;
|
||||
//
|
||||
// // text colors
|
||||
// --c-text: #2c3e50;
|
||||
// --c-text-accent: var(--c-brand);
|
||||
// --c-text-light: #3a5169;
|
||||
// --c-text-lighter: #4e6e8e;
|
||||
// --c-text-lightest: #6a8bad;
|
||||
// --c-text-quote: #999999;
|
||||
//
|
||||
// // border colors
|
||||
// --c-border: #eaecef;
|
||||
// --c-border-dark: #dfe2e5;
|
||||
//
|
||||
// // custom container colors
|
||||
// --c-tip: #42b983;
|
||||
// --c-tip-bg: var(--c-bg-light);
|
||||
// --c-tip-title: var(--c-text);
|
||||
// --c-tip-text: var(--c-text);
|
||||
// --c-tip-text-accent: var(--c-text-accent);
|
||||
// --c-warning: #e7c000;
|
||||
// --c-warning-bg: #fffae3;
|
||||
//--c-warning-title: #ad9000;
|
||||
//--c-warning-text: #746000;
|
||||
//--c-warning-text-accent: var(--c-text);
|
||||
//--c-danger: #cc0000;
|
||||
//--c-danger-bg: #ffe0e0;
|
||||
//--c-danger-title: #990000;
|
||||
//--c-danger-text: #660000;
|
||||
//--c-danger-text-accent: var(--c-text);
|
||||
//--c-details-bg: #eeeeee;
|
||||
//
|
||||
//// badge component colors
|
||||
//--c-badge-tip: var(--c-tip);
|
||||
//--c-badge-warning: var(--c-warning);
|
||||
//--c-badge-danger: var(--c-danger);
|
||||
//
|
||||
//// transition vars
|
||||
//--t-color: 0.3s ease;
|
||||
//--t-transform: 0.3s ease;
|
||||
//
|
||||
//// code blocks vars
|
||||
//--code-bg-color: #282c34;
|
||||
//--code-hl-bg-color: rgba(0, 0, 0, 0.66);
|
||||
//--code-ln-color: #9e9e9e;
|
||||
//--code-ln-wrapper-width: 3.5rem;
|
||||
//
|
||||
//// font vars
|
||||
//--font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen,
|
||||
// Ubuntu, Cantarell, 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
|
||||
//--font-family-code: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
||||
//
|
||||
//// layout vars
|
||||
//--navbar-height: 3.6rem;
|
||||
//--navbar-padding-v: 0.7rem;
|
||||
//--navbar-padding-h: 1.5rem;
|
||||
//--sidebar-width: 20rem;
|
||||
//--sidebar-width-mobile: calc(var(--sidebar-width) * 0.82);
|
||||
//--content-width: 740px;
|
||||
//--homepage-width: 960px;
|
||||
//}
|
||||
//
|
||||
//// plugin-back-to-top
|
||||
//.back-to-top {
|
||||
//--back-to-top-color: var(--c-brand);
|
||||
//--back-to-top-color-hover: var(--c-brand-light);
|
||||
//}
|
||||
//
|
||||
//// plugin-docsearch
|
||||
//.DocSearch {
|
||||
//--docsearch-primary-color: var(--c-brand);
|
||||
//--docsearch-text-color: var(--c-text);
|
||||
//--docsearch-highlight-color: var(--c-brand);
|
||||
//--docsearch-muted-color: var(--c-text-quote);
|
||||
//--docsearch-container-background: rgba(9, 10, 17, 0.8);
|
||||
//--docsearch-modal-background: var(--c-bg-light);
|
||||
//--docsearch-searchbox-background: var(--c-bg-lighter);
|
||||
//--docsearch-searchbox-focus-background: var(--c-bg);
|
||||
//--docsearch-searchbox-shadow: inset 0 0 0 2px var(--c-brand);
|
||||
//--docsearch-hit-color: var(--c-text-light);
|
||||
//--docsearch-hit-active-color: var(--c-bg);
|
||||
//--docsearch-hit-background: var(--c-bg);
|
||||
//--docsearch-hit-shadow: 0 1px 3px 0 var(--c-border-dark);
|
||||
//--docsearch-footer-background: var(--c-bg);
|
||||
//}
|
||||
//
|
||||
//// plugin-external-link-icon
|
||||
//.external-link-icon {
|
||||
//--external-link-icon-color: var(--c-text-quote);
|
||||
//}
|
||||
//
|
||||
//// plugin-medium-zoom
|
||||
//.medium-zoom-overlay {
|
||||
//--medium-zoom-bg-color: var(--c-bg);
|
||||
//}
|
||||
//
|
||||
//// plugin-nprogress
|
||||
//#nprogress {
|
||||
//--nprogress-color: var(--c-brand);
|
||||
//}
|
||||
//
|
||||
//// plugin-pwa-popup
|
||||
//.pwa-popup {
|
||||
//--pwa-popup-text-color: var(--c-text);
|
||||
//--pwa-popup-bg-color: var(--c-bg);
|
||||
//--pwa-popup-border-color: var(--c-brand);
|
||||
//--pwa-popup-shadow: 0 4px 16px var(--c-brand);
|
||||
//--pwa-popup-btn-text-color: var(--c-bg);
|
||||
//--pwa-popup-btn-bg-color: var(--c-brand);
|
||||
//--pwa-popup-btn-hover-bg-color: var(--c-brand-light);
|
||||
//}
|
||||
//
|
||||
//// plugin-search
|
||||
//.search-box {
|
||||
//--search-bg-color: var(--c-bg);
|
||||
//--search-accent-color: var(--c-brand);
|
||||
//--search-text-color: var(--c-text);
|
||||
//--search-border-color: var(--c-border);
|
||||
//
|
||||
//--search-item-text-color: var(--c-text-lighter);
|
||||
//--search-item-focus-bg-color: var(--c-bg-light);
|
||||
//}
|
||||
|
||||
@@ -1,2 +1,6 @@
|
||||
// 主题色
|
||||
$theme-color: #2196f3;
|
||||
$theme-color: #2980B9;
|
||||
$sidebar-width: 20rem;
|
||||
$sidebar-mobile-width: 16rem;
|
||||
$content-width: 75rem;
|
||||
$home-page-width:80rem;
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
## 网站大事记
|
||||
# 网站大事记
|
||||
|
||||
|
||||
> 有时间再梳理梳理吧....
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
|
||||
|
||||
## 计算机网络
|
||||
|
||||
doing
|
||||
1455
docs/ds/README11.md
@@ -1,109 +0,0 @@
|
||||
<!--
|
||||
* @Description:
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2022-04-08 23:10:00
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2022-04-23 18:06:18
|
||||
-->
|
||||
|
||||
## 写在最前面
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
这份《薛定谔的Egg.js》文档,是我考虑很久之后,才决定要整理出来的,在这上面倾注了很多时间
|
||||
|
||||
|
||||
- 也不知道有没有用
|
||||
- 也不知道能不能整理完
|
||||
- 更不知道对你会不会有所帮助
|
||||
|
||||
|
||||
但愿我们都能在此有所收获,放手开始吧!!
|
||||
|
||||
|
||||
最后,仅以“**祷以恒切, 盼以喜乐,苦以坚忍,必有所得**”,共勉~
|
||||
|
||||
|
||||
---
|
||||
|
||||
|
||||
## 阅读须知
|
||||
|
||||
|
||||
- 该部分为框架基础,是基于[Egg.js官网](https://eggjs.org/zh-cn/)和自己使用体验进行整理汇总,难免会存在重复部分。
|
||||
- 若在阅读、学习过程中发现与官网描述有所差异,可以立即与我联系进行确认与更改。
|
||||
- **文档用于个人整理和技术学习,禁止无授权转载、商用。**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## 技术支持
|
||||
|
||||
- [Egg.js官网](https://eggjs.org/zh-cn/)
|
||||
- [VuePress](https://www.vuepress.cn/guide)
|
||||
- [AntDocs](https://antdocs.seeyoz.cn/guide/)
|
||||
|
||||
|
||||
|
||||
## 适用群体
|
||||
|
||||
|
||||
- 默认已了解过[ES6](https://es6.ruanyifeng.com/)语法和部分Node后端框架([Express](https://www.expressjs.com.cn/)、[Koa](https://koa.bootcss.com/))。
|
||||
- 具有一定JavaScript开发基础,对JavaScript开发有浓烈兴趣。
|
||||
- **已有Egg.js开发经验,但细节用法不胜了解的,非常适合用来查缺补漏。**
|
||||
|
||||
|
||||
## 资料共享
|
||||
|
||||
> 链接失效可以关注公众号或私信获取"链接"
|
||||
|
||||
## 参考资料
|
||||
|
||||
- 大话数据结构 - 程杰
|
||||
- 数据结构复习全书 - 王道论坛
|
||||
- 视频教程 - 王道论坛
|
||||
|
||||
---
|
||||
|
||||
### 联系我
|
||||
|
||||
- 有任何问题或建议,欢迎微信“骚扰”,商务合作请备注!
|
||||
|
||||
<div align="left">
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/wechat_code.jpg" width="300" height="300" style="border-radius:4px;"/>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
#
|
||||
|
||||
### 公众号
|
||||
|
||||
|
||||
- 相逢不用忙归去,明日黄花蝶也愁....
|
||||
|
||||
- **若系列文章对你有所帮助,不如来公众号交个朋友吧.**
|
||||
|
||||
<a name="gzh"></a>
|
||||
|
||||
|
||||
<p>
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/gongzhonghao.jpg" style="border-radius:10px;">
|
||||
</p>
|
||||
|
||||
交流/加群/互看朋友圈
|
||||
当然:**聊天 /提问 /建议 /提需求** 可以在本公众号直接**私信**,后台可以看到,有时间即会回复,偶尔的延迟和疏漏还请小伙伴们谅解,蟹蟹。
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export default [
|
||||
export const algorithmSidebar = [
|
||||
{
|
||||
text: '基础入门',
|
||||
link: "/ds/basic_introduction",
|
||||
@@ -7,7 +7,8 @@
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2022-04-24 08:12:21
|
||||
-->
|
||||
## 计算机组成原理
|
||||
|
||||
# 计算机组成原理
|
||||
|
||||
|
||||
doing
|
||||
1
docs/manuscripts/ccp/cpp.sidebar.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const cppSidebar=[]
|
||||
5
docs/manuscripts/cn/Readme.md
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
|
||||
# 计算机网络
|
||||
|
||||
doing
|
||||
1
docs/manuscripts/cn/cn.sidebar.ts
Normal file
@@ -0,0 +1 @@
|
||||
export const cnSidebar=[]
|
||||
|
Before Width: | Height: | Size: 650 KiB After Width: | Height: | Size: 650 KiB |
80
docs/manuscripts/ds/ds.sidebar.ts
Normal file
@@ -0,0 +1,80 @@
|
||||
export const dsSidebar = [
|
||||
{
|
||||
text: '基础入门',
|
||||
prefix: "basic-introduction",
|
||||
collapsible: false,
|
||||
children: [{
|
||||
text: '1.1 基本概念',
|
||||
link: '1.basic_concepts.md'
|
||||
}, {
|
||||
text: '1.2 数据结构三要素',
|
||||
link: '2.three_elements_of_data_structure.md'
|
||||
}, {
|
||||
text: '1.3 算法和算法评价',
|
||||
link: '3.algorithm_and_algorithm_evaluation.md'
|
||||
}],
|
||||
},
|
||||
{
|
||||
text: '线性表',
|
||||
collapsible: false,
|
||||
prefix: "linear-table",
|
||||
children: [{
|
||||
text: '2.1 基础概念和操作',
|
||||
link: '1.basic_concept_and_operation.md'
|
||||
}, {
|
||||
text: '2.2 线性表的顺序表示',
|
||||
link: '2.sequential_representation.md'
|
||||
}, {
|
||||
text: '2.3 基础概念和操作',
|
||||
link: '3.chain_representation.md'
|
||||
}, {
|
||||
text: '2.4 基础概念和操作',
|
||||
link: '4.double_linked_list.md'
|
||||
}, {
|
||||
text: '2.5 基础概念和操作',
|
||||
link: '5.circular_list.md'
|
||||
}, {
|
||||
text: '2.6 基础概念和操作',
|
||||
link: '6.static_linked_list.md'
|
||||
}, {
|
||||
text: '2.7 基础概念和操作',
|
||||
link: '7.comparison_of_sequential_list_and_linked_list.md'
|
||||
}, {
|
||||
text: '2.8 存储结构的选取',
|
||||
link: '8.selection_of_storage_structure.md'
|
||||
}, {
|
||||
text: '2.9 零碎知识补充',
|
||||
link: '9.piecemeal_knowledge_supplement.md'
|
||||
}],
|
||||
},
|
||||
{
|
||||
text: "栈和队列",
|
||||
prefix: "栈和队列",
|
||||
collapsible: false,
|
||||
children: [{
|
||||
text: '3.1 栈的基本概念和基本操作',
|
||||
link: '1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.2 栈的顺序存储结构',
|
||||
link: '2.栈的顺序存储结构.md'
|
||||
}, {
|
||||
text: '3.3 栈的基本概念和基本操作',
|
||||
link: '1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.4 栈的基本概念和基本操作',
|
||||
link: '1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.5 栈的基本概念和基本操作',
|
||||
link: '1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.6 栈的基本概念和基本操作',
|
||||
link: '1.栈的基本概念和基本操作.md'
|
||||
}, {
|
||||
text: '3.7 栈和队列的应用',
|
||||
link: '7.栈和队列的应用.md'
|
||||
}, {
|
||||
text: '3.8 特殊矩阵的压缩存储',
|
||||
link: '8.特殊矩阵的压缩存储.md'
|
||||
}]
|
||||
}
|
||||
]
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
## 线性表的基础概念和基本操作
|
||||
# 线性表的基础概念和基本操作
|
||||
|
||||
> 强调线性表是一种逻辑结构,不是存储结构
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
-->
|
||||
|
||||
|
||||
## 线性表的顺序表示
|
||||
# 线性表的顺序表示
|
||||
|
||||
|
||||
### 定义
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
## 线性表的链式表示
|
||||
# 线性表的链式表示
|
||||
|
||||
顺序表的插入、删除操作需要移动大量元素,影响了运行效率(虽然时间复杂度为O(1)的情况也存在)。
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
## 双链表
|
||||
# 双链表
|
||||
|
||||
|
||||
从单链表的结构上来看
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
## 循环链表
|
||||
# 循环链表
|
||||
|
||||
- 循环单链表
|
||||
- 循环双链表
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
## 静态链表
|
||||
# 静态链表
|
||||
|
||||
> 借助数组来描述线性表的链式存储结构,结点元素同样存在数据域`data`和指针域`next`
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
## 顺序表和链表的比较
|
||||
# 顺序表和链表的比较
|
||||
|
||||
|
||||
### 存取方式
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
|
||||
## 存储结构的选取
|
||||
# 存储结构的选取
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
|
||||
|
||||
## 零碎知识补充
|
||||
# 零碎知识补充
|
||||
|
||||
- 无论是链表的插入还是删除操作,必须保证不断链【重要】
|
||||
- 顺序存储结构可以随机存取也能顺序存取,链式结构只能进行顺序存取
|
||||
@@ -7,5 +7,6 @@
|
||||
* @LastEditTime: 2022-04-24 09:03:44
|
||||
-->
|
||||
|
||||
# 线性表
|
||||
|
||||

|
||||
|
Before Width: | Height: | Size: 2.0 MiB After Width: | Height: | Size: 2.0 MiB |
332
docs/manuscripts/ds/readme.md
Normal file
@@ -0,0 +1,332 @@
|
||||
---
|
||||
title: 线性表
|
||||
---
|
||||
|
||||
|
||||
<!--
|
||||
* @Description:
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-07 21:57:27
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2022-04-23 18:22:12
|
||||
-->
|
||||
|
||||
|
||||
|
||||
<!-- ## 线性表的基础概念和基本操作 -->
|
||||
|
||||
## 基础概念和基本操作
|
||||
|
||||
> 强调线性表是一种逻辑结构,不是存储结构
|
||||
|
||||
|
||||
### 定义
|
||||
|
||||
线性表是具有相同数据类型的n(n≥0)个数据元素的有限序列。一般表示:
|
||||
|
||||
L=(a<sub>1</sub>,a<sub>2</sub>,a<sub>3</sub>......a<sub>n</sub>) 其中n可以理解为表长(线性表的长度),n=0时候,即表空
|
||||
|
||||
|
||||
- `表头元素`:线性表中唯一的“第一个”数据元素,例如a<sub>1</sub>
|
||||
- `表尾元素`:线性表中唯一的“最后一个”数据元素,例如a<sub>n</sub>
|
||||
|
||||
|
||||
重要逻辑特性:
|
||||
|
||||
- 除表头元素外,线性表中每个元素有且仅有一个`直接前驱`
|
||||
- 除表尾元素外,线性表中每个元素有且仅有一个`直接后继`
|
||||
|
||||
基于此,这种**线性有序的逻辑结构**,使得线性表的特点如下:
|
||||
|
||||
- 元素的**个数有限**(强调有限序列)
|
||||
- 元素在逻辑上具有**顺序性**,在序列中每个元素都是都有先后次序的
|
||||
- 元素都数据元素,**每个元素都是单个元素**
|
||||
- 元素的**数据类型都相同**(强调相同数据类型),每个数据元素占用相同大小的存储空间
|
||||
- 元素具有**抽象性**,仅仅讨论元素之间的逻辑关系,不需要去考虑元素究竟表示的什么内容
|
||||
|
||||
|
||||
> Tips: **线性表是一种逻辑结构**,表示元素之间一对一的相邻关系。**顺序表和链表则指的是存储结构**
|
||||
|
||||
|
||||
|
||||
### 基本操作
|
||||
|
||||
- `InitList(&L)`: **初始化表**。构造空的线性表
|
||||
- `Length(L)`:**获取表的长度**。返回线性表L的长度,即表中的数据元素个数
|
||||
- `LocateElem(L,e)`:**按值查找操作**。在表L中国查找具有给定关键字的元素
|
||||
- `GetElem(L,i)`:**按位查找操作**。获取表中第i个位置的元素的值
|
||||
- `ListInsert(&L,i,e)`:**插入操作**。在表的第i个位置上插入指定元素e
|
||||
- `ListDelete(&L,i,&e)`:**删除操作**。删除表中第i个位置的元素,并用e返回删除元素的值
|
||||
- `PrintList(L)`:**输出操作**。按照前后顺序(如:1、2....n)输出线性表的所有元素值
|
||||
- `Empty(L)`:**判空操作**。当表L为空,则返回true,否则返回false
|
||||
- `DestoryList(&L)`:**销毁操作**。将线性表销毁,释放线性表L所占用的内存空间(类似:释放内存)
|
||||
|
||||
|
||||
线性表是具有相同的数据类型的有限个数据元素组成的,**数据元素是由数据项组成的**
|
||||
|
||||
|
||||
## 线性表的顺序表示
|
||||
|
||||
|
||||
### 定义
|
||||
|
||||
`顺序表`:顺序存储的线性表,**是用一组地址连续的存储单元,依次存储线性表中的数据元素,使得在逻辑上相邻的两个元素在物理位置上也相邻。**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
顺序表中的元素的逻辑顺序与实际的物理位置相同
|
||||
|
||||
|
||||
|
||||
注意:
|
||||
|
||||
- 线性表中的元素的位序是从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;
|
||||
|
||||
```
|
||||
|
||||
动态分配语句
|
||||
|
||||
```cpp
|
||||
// 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
|
||||
|
||||
/*
|
||||
* @Description: 顺序表的插入操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-02-23 07:48:26
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-02-23 07:48:26
|
||||
*/
|
||||
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
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 顺序表的删除操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-02-23 07:48:26
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-02-23 07:48:26
|
||||
*/
|
||||
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<L.length;i++){
|
||||
if(L.data[i]===e){
|
||||
// i是元素的角标,i+1是具体元素的位序号
|
||||
return i+1;
|
||||
}
|
||||
}
|
||||
|
||||
// 未命中,返回0,即:没有
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
注意理解`位序`的含义,即元素在线性表中的位置序号,角标为`i`(角标从0开始),对应的位序为`i+1`(位序从1开始)。当返回为0时,则直接代表没有`命中`;
|
||||
|
||||
|
||||
**时间复杂度:**
|
||||
|
||||
- 最好情况:查找的元素在表头,只需要比较一次,循环成本最小,时间复杂度为O(1);
|
||||
- 最坏情况:查找的元素在表尾或者不存在,需要完整遍历,比较n次,时间复杂度为O(n);
|
||||
- 平均情况:随机查找表上的第i个(1≤i≤L.length)元素,平均次数为(n+1)/2,对应时间复杂度为O(n)
|
||||
|
||||
|
||||
|
||||
**线性表按值查找(顺序查找)的平均时间复杂度为O(n);**
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
**顺序存取是读写方式,不是存储结构;顺序存储是存储结构,包括有:顺序存储、链式存储、索引存储、散列存储**
|
||||
62
docs/manuscripts/ds/栈和队列/1.栈的基本概念和基本操作.md
Normal file
@@ -0,0 +1,62 @@
|
||||
<!--
|
||||
* @Description: 基本概念和基本操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-01-11 23:56:02
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-12 00:02:55
|
||||
-->
|
||||
|
||||
|
||||
|
||||
# 基本概念和基本操作
|
||||
|
||||
`栈`: 只允许在一端进行插入或者删除操作的**线性表**,`后进先出的线性表`。
|
||||
|
||||
|
||||
- 明确栈是一种线性表
|
||||
- 限定栈只能在某一端进行插入或者删除操作
|
||||
|
||||

|
||||
|
||||
`栈顶`:线性表允许进行插入和删除的一端。
|
||||
|
||||
`栈底`:不允许进行插入和删除的另外一端,是**固定的**。类似杯底这中概念
|
||||
|
||||
`空栈`:不含任何元素的空表,也叫**栈空**
|
||||
|
||||
|
||||
|
||||
基本结构如下:
|
||||
|
||||
|
||||
|
||||
|
||||
在上面的基本结构中,可以假设存在栈S=(a1,a2,a3,a4,a5,a6,a7,a8),很明显
|
||||
|
||||
- 栈顶元素:a1
|
||||
- 栈底元素:a8
|
||||
|
||||
|
||||
栈只能在栈顶进行插入和删除操作
|
||||
|
||||
- 进栈顺序:a1->a2->a3->a4->a5->a6->a7->a8
|
||||
- 出栈顺序:a8->a7->a6->a5->a4->a3->a2->a1
|
||||
|
||||
|
||||
可以得出结论:栈是后进先出(先进后出),即:LIFO(Last In First Out),也可以叫**后进先出的线性表**
|
||||
|
||||
|
||||
## 栈的基本操作
|
||||
|
||||
|
||||
- `InitStack(&S)`: 初始化一个空栈`S`,栈顶指针初始化为-1
|
||||
- `StackEmpty(S)`: 判断一个栈是否为空,如果栈空则返回`true`,否则返回`false`
|
||||
- `Push(&S,x)`: 进栈,若栈未满,`x`进栈操作,插入到栈内成为`新的栈顶元素`。
|
||||
- `Pop(&S,&x)`: 出栈,若栈非空,出栈操作,**弹出栈顶元素**,用指针`x`进行返回。
|
||||
- `GetTop(S,&x)`: 读栈顶元素,若栈`S`非空,用x返回栈顶元素。
|
||||
- `ClearStack(&S)`: 销毁栈,释放栈`S`占用的存储空间。
|
||||
|
||||
|
||||
|
||||
> Tips: `&`是C++特有的,可以用来表示引用调用,类似`传址目的`,可以类比指针。 当然,在C语言中*代表指针,指向存储地址,也是具有`传址目的`
|
||||
232
docs/manuscripts/ds/栈和队列/2.栈的顺序存储结构.md
Normal file
@@ -0,0 +1,232 @@
|
||||
<!--
|
||||
* @Description: 栈的顺序存储结构
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-01-15 16:57:37
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-12 08:05:50
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
# 栈的顺序存储结构
|
||||
|
||||
|
||||
`顺序栈`:栈的顺序存储,利用一组地址连续的存储单元存放自栈底到栈顶的所有元素,同时**附加一个用来指向当前栈顶位置的指针**
|
||||
|
||||
> 指针指向栈顶(top)主要是因为栈在线性表的一端操作,操作的那端就是栈顶,方便操作。
|
||||
|
||||
|
||||
### 顺序栈的存储类型
|
||||
|
||||
```C++
|
||||
// 定义栈中元素的最大个数
|
||||
# define MaxSize 50
|
||||
|
||||
// 结构体定义
|
||||
typedef struct{
|
||||
ElemType data[MaxSize]; // 存放栈中元素
|
||||
int top; // 栈顶指针
|
||||
}SqStack;
|
||||
|
||||
```
|
||||
|
||||
假设存在顺序栈S,则:
|
||||
|
||||
- 栈顶指针:S.top 初始化时设置S.top=-1
|
||||
- 栈顶元素:S.data[S.top],其中S.top为栈顶指针
|
||||
- 进栈操作:栈不满时,栈顶指针+1,再送值到栈顶元素
|
||||
- 出栈操作:栈非空时,先取栈顶元素值,再将栈顶指针-1
|
||||
- 栈空条件:S.top=-1
|
||||
- 栈满条件:S.top=MaxSize-1
|
||||
- 栈长:S.top+1
|
||||
|
||||
|
||||
> Tips: 进栈先移动指针,避免占满,元素无法添加,出现外溢;出栈先取栈顶元素,保证指针永远指向栈顶。
|
||||
|
||||
|
||||
|
||||
顺序栈的存储结构体定义可以很明显看出,顺序栈的入栈操作会受到数组上界(MaxSize)的约束。
|
||||
|
||||
**当对栈的最大使用空间估计不足时,容易出现栈上溢(外溢),需要主动向用户报告反馈,避免出现错误;**
|
||||
|
||||
|
||||
|
||||
### 顺序栈的基本运算
|
||||
|
||||
|
||||
- `InitStack(&S)`: 初始化一个空栈`S`,栈顶指针初始化为-1
|
||||
- `StackEmpty(S)`: 判断一个栈是否为空,如果栈空则返回`true`,否则返回`false`
|
||||
- `Push(&S,x)`: 进栈,若栈未满,`x`进栈操作,插入到栈内成为`新的栈顶元素`。
|
||||
- `Pop(&S,&x)`: 出栈,若栈非空,出栈操作,**弹出栈顶元素**,用指针`x`进行返回。
|
||||
- `GetTop(S,&x)`: 读栈顶元素,若栈`S`非空,用x返回栈顶元素。
|
||||
- `ClearStack(&S)`: 销毁栈,释放栈`S`占用的存储空间。
|
||||
|
||||
|
||||
#### 初始化
|
||||
|
||||
|
||||
`InitStack(&S)`: 初始化一个空栈`S`,栈顶指针初始化为-1
|
||||
|
||||
```C++
|
||||
|
||||
void InitStack(&S){
|
||||
// 栈顶指针-1
|
||||
s.top=-1;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 栈空判断
|
||||
|
||||
`StackEmpty(S)`: 判断一个栈是否为空,即:栈顶指针是否为-1,如果栈空则返回`true`,否则返回`false`
|
||||
|
||||
```C++
|
||||
|
||||
bool StackEmpty(S){
|
||||
if(S.top==-1){
|
||||
// 栈空
|
||||
return true;
|
||||
}else{
|
||||
// 栈非空
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 进栈
|
||||
|
||||
|
||||
`Push(&S,x)`: 进栈,若栈未满,`x`进栈操作,插入到栈内成为`新的栈顶元素`。
|
||||
|
||||
```C++
|
||||
|
||||
bool Push(SqStack &S,ElemType x){
|
||||
if(S.top==MaxSize-1){
|
||||
// 栈满,返回false,元素无法进行进栈操作
|
||||
return false;
|
||||
}else{
|
||||
// 可进栈,栈顶指针+1,再元素入栈
|
||||
S.data[++S.top]=x;
|
||||
|
||||
// 入栈成功
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
注意:
|
||||
|
||||
- 进栈先移动栈顶指针+1,再操作入栈元素
|
||||
- `++i`是简写,先对变量i进行递加操作,再进行使用,即:先加后用
|
||||
|
||||
#### 出栈
|
||||
|
||||
`Pop(&S,&x)`: 出栈,若栈非空,出栈操作,**弹出栈顶元素**,用指针`x`进行返回。
|
||||
|
||||
```C++
|
||||
|
||||
bool Pop(SqStack &S,ElemType &x){
|
||||
if(S.top==-1){
|
||||
// 栈空,无栈顶元素可出栈,返回false
|
||||
return false;
|
||||
}else{
|
||||
// 栈非空,先元素出栈,再进行指针-1
|
||||
x=S.data[S.top--];
|
||||
|
||||
// 出栈成功,返回true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
注意:
|
||||
|
||||
- 出栈操作,先让元素出栈,获取栈顶元素,再移动指针-1
|
||||
- `i--`是先使用变量i,再对变量做递减操作,即:先用后加(减)
|
||||
|
||||
|
||||
|
||||
#### 读(获取)栈顶元素
|
||||
|
||||
`GetTop(S,&x)`: 读栈顶元素,若栈`S`非空,用x返回栈顶元素。
|
||||
|
||||
```C++
|
||||
|
||||
bool GetTop(SqStack S,ElemType &x){
|
||||
|
||||
if(S.top==-1){
|
||||
// 栈空,无栈顶元素,返回false
|
||||
return false;
|
||||
}else{
|
||||
|
||||
// 通过栈顶指针,获取栈顶元素,赋值给变量x
|
||||
x=S.data[S.top];
|
||||
|
||||
// 读取栈顶元素成功,返回true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
**上面的这些操作都是基于栈顶指针初始化为`-1`的情况**
|
||||
|
||||
当栈顶指针初始化为`S.top=0`,相关操作操作会有区别:
|
||||
|
||||
- 入栈: `S.data[S.top++]=x`
|
||||
- 出栈: `x=S.data[--S.top]`
|
||||
|
||||
|
||||
**同时, 栈空、栈满条件也会有变化,要仔细对比揣摩**
|
||||
|
||||
|
||||
|
||||
### 共享栈
|
||||
|
||||
|
||||
`共享栈`:利用栈底位置相对不变的特性,可以让两个顺序栈共享一个`一维存储空间`,将两个栈的栈底分别设置在共享空间的两端,两个栈顶则向共享空间的中间延伸
|
||||
|
||||
>Tips: 类似头对头,一致对外这种感觉,噗呲哈哈
|
||||
|
||||

|
||||
|
||||
|
||||
在上面的共享栈结构图中,两个栈(0、1号顺序栈)的栈顶指针都指向栈顶元素
|
||||
|
||||
- 0号栈栈顶指针`top=-1`时,0号栈为空
|
||||
- 1号栈栈顶指针`top=MaxSize`时,1号栈为空
|
||||
|
||||
当且仅当两个栈的栈顶指针相邻(`top1-top0=1`),可以判断共享栈栈满
|
||||
|
||||
|
||||
#### 进栈
|
||||
|
||||
|
||||
> 进栈:先移动指针,后进行赋值
|
||||
|
||||
|
||||
- 当0号栈进栈时,0号栈栈顶指针top0`先加1后赋值`
|
||||
- 当1号栈进栈时,0号栈栈顶指针top1`先减1后赋值`
|
||||
|
||||
#### 出栈
|
||||
|
||||
> 出栈:先进行赋值,后移动指针
|
||||
|
||||
|
||||
- 当0号栈进栈时,0号栈栈顶指针top0`先赋值后减1`
|
||||
- 当1号栈进栈时,0号栈栈顶指针top1`先赋值后加1`
|
||||
|
||||
|
||||
|
||||
共享栈能够更有效的利用存储空间,两个栈空间进行相互调节。只有当这个存储空间(即:共享空间)被占满时才会发生上溢。存取数据的时间复杂度都为O(1),在栈顶操作。
|
||||
|
||||
|
||||
**共享栈对存取效率没有什么影响**
|
||||
140
docs/manuscripts/ds/栈和队列/3.栈的链式存储结构.md
Normal file
@@ -0,0 +1,140 @@
|
||||
<!--
|
||||
* @Description: 栈的链式存储结构
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-12 08:15:40
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-13 17:05:26
|
||||
-->
|
||||
|
||||
|
||||
# 栈的链式存储结构
|
||||
|
||||
`链栈`: 采用链式存储的栈
|
||||
|
||||
`栈满`:对于链栈来说,是基于链式存储的,基本不存在栈满的情况,除非内存已经没有使用空间了。
|
||||
|
||||
`栈空`:对于空栈来说,链表原来的定义是头指针指向空,那么链栈的空其实就是`top=NULL`,链栈元素总数为0
|
||||
|
||||
|
||||
栈只是栈顶在做插入和删除操作,栈顶应该放在单链表的头部,所以单链表中的头结点也就失去了意义。
|
||||
|
||||
**通常对于链栈来说,是不需要头结点的,当然也存在带头结点的链栈**
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
栈的链式存储类型:
|
||||
|
||||
```C++
|
||||
|
||||
// 链栈类型定义【基础】
|
||||
typedef struct LinkNode{
|
||||
ElemType data; // 栈元素结点数据域
|
||||
struct LinkNode *next; // 栈元素结点指针域
|
||||
} *LinkStack;
|
||||
|
||||
// 更为详细的定义
|
||||
|
||||
typedef struct StackNode
|
||||
{
|
||||
int data;//结点数据域
|
||||
struct StackNode* next;//结点指针域
|
||||
}StackNode,* Linktop;
|
||||
|
||||
//链栈的数据结构
|
||||
typedef struct LinkStack
|
||||
{
|
||||
Linktop top; //栈顶结点,定义了一个指向上个结构体的指针
|
||||
int count;//元素个数
|
||||
}LinkStack;
|
||||
|
||||
```
|
||||
|
||||
### 优点
|
||||
|
||||
- 便于多个栈共享存储空间
|
||||
- 不存在栈满上溢的情况,避免程序因溢出导致出错
|
||||
- 有效的提高存取效率
|
||||
|
||||
|
||||
### 进栈
|
||||
|
||||
- 如果链栈不存在,则栈满,入栈操作失败,返回false;
|
||||
- 如果链栈存在,进行单链表的结点插入操作,移动指针,结点元素赋值,再将结点压入链栈中,移动链栈栈顶指针,最后链栈元素总数+1,返回true
|
||||
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 基于单链表链栈的进栈操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 07:36:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 11:39:16
|
||||
*/
|
||||
bool linkStackPushNode(LinkStack* linkStack,int e){
|
||||
|
||||
// 判断链栈是否存在
|
||||
if (!linkStack){
|
||||
//链栈不存在,无法进栈操作,返回false
|
||||
return false;
|
||||
}
|
||||
// 开辟栈结点元素内存控件
|
||||
StackNode* node = (StackNode*)malloc(sizeof(StackNode));
|
||||
// 新结点指针域指向链表,即栈顶指针位置,元素加入链表
|
||||
node->next = linkStack->top;
|
||||
// 新结点数据域赋值
|
||||
node->data = e;
|
||||
// 元素进栈,移动栈顶指针,指向新入栈的元素
|
||||
linkStack->top = node;
|
||||
// 链栈元素总数+1
|
||||
linkStack->count++;
|
||||
//链栈入栈成功,返回true
|
||||
return true;
|
||||
}
|
||||
```
|
||||
|
||||
### 出栈
|
||||
|
||||
- 如果链栈不存在,或者为空栈,则无法进行出栈操作,返回false
|
||||
- 如果链栈满足出栈条件,则通过栈顶指针获取到链栈栈底结点,将其数据域赋值给变量e,移动栈顶指针指向待出栈元素的后继结点,同时释放待出栈元素的内存空间,链栈元素总数-1 ,出栈成功,返回true.
|
||||
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 基于单链表链栈的出栈操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-04 23:38:04
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2020-03-04 23:39:16
|
||||
*/
|
||||
bool linkStackPopNode(LinkStack* linkStack,int *e){
|
||||
// 判断链栈是否存在及是否为空
|
||||
if (!linkStack || linkStack->count==0){
|
||||
//出栈失败,返回false
|
||||
return false;
|
||||
}
|
||||
// 获取栈顶元素结点
|
||||
StackNode* node = stack->top;
|
||||
|
||||
// 结点元素数据域赋值给变量e
|
||||
*e = linkStack->data;
|
||||
// 移动栈顶指向,栈顶指针指向待出栈结点的后继结点
|
||||
linkStack->top = node->next;
|
||||
// 变量e已被赋值,释放链栈出栈元素的内存控件
|
||||
free(node);
|
||||
// 链栈元素个数-1
|
||||
linkStack->count--;
|
||||
// 出栈成功,返回true.
|
||||
return true;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
以上是基于单链表的链栈入栈、出栈操作,很明显**时间复杂度都为O(1)**,重点`注意移动指针,保持不断链`
|
||||
53
docs/manuscripts/ds/栈和队列/4.队列的基本概念和基础操作.md
Normal file
@@ -0,0 +1,53 @@
|
||||
<!--
|
||||
* @Description: 队列的基本概念和基础操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-18 06:15:40
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-14 11:08:32
|
||||
-->
|
||||
|
||||
|
||||
|
||||
# 队列的基本概念和基础操作
|
||||
|
||||
|
||||
### 基本概念
|
||||
|
||||
`队列`:和栈一样,是一种操作受限制的线性表,只允许在表的一端进行插入,在表的另外一端进行删除,简称为`队`,常记作:`Queue`
|
||||
|
||||
`入队`: 向队列中插入元素,也叫做`进队`
|
||||
|
||||
`出队`: 删除队列元素,也叫做`离队`
|
||||
|
||||
|
||||

|
||||
|
||||
结合生活中排队的经验,在群体素质高、无人插队的情况下(`薛定谔排队`,噗呲,哈哈哈),**一般最早排队的也是最早离队的**,和栈的`后进先出`不一样的是,队列是`先进先出`的,即:First In Frist Out
|
||||
|
||||
> Tips
|
||||
> - 栈:又叫做后进先出的线性表
|
||||
> - 队列:又叫做先进先出的线性表
|
||||
|
||||
|
||||
|
||||
`队头`:允许进行删除操作的一端,也叫做`队首`,常记作:`Front`
|
||||
|
||||
`队尾`:允许进行插入操作的一端,常记作:`Rear`
|
||||
|
||||
`空队列`:不含任何元素的空表,注意这个表是指`线性表`
|
||||
|
||||
|
||||
|
||||
|
||||
### 基础操作
|
||||
|
||||
|
||||
> 和栈一样,队列是操作受限的线性表,具有`先进先出`的特性,不是任何对线性表的操作都可以作为队列的操作。例如:无法随便读取到队列中间的某个数据,需要将前面的元素先出队
|
||||
|
||||
|
||||
- `InitQueue(&Q)`: 初始化一个队列,构造空队列Q
|
||||
- `QueueEmpty(Q)`: 判断队列是否为空,队空返回true,否则返回false
|
||||
- `EnEmpty(&Q,x)`: 入队,如果队列Q未满,将x入队,成为新的队尾元素
|
||||
- `DeEmpty(&Q,&x)`: 出队,如果队列Q非空,删除队头元素,复制给x返回
|
||||
- `GetHead(Q,&x)`: 读取队头元素,如果队列Q非空,则将队头元素赋值给x
|
||||
346
docs/manuscripts/ds/栈和队列/5.队列的顺序存储结构.md
Normal file
@@ -0,0 +1,346 @@
|
||||
<!--
|
||||
* @Description:
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-03-1 07:23:48
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 23:51:35
|
||||
-->
|
||||
|
||||
|
||||
# 队列的顺序存储结构
|
||||
|
||||
|
||||
> 队列的顺序实现是指分配一块连续的存储单元用来存放队列中的元素,并且附加两个指针。
|
||||
> - `front指针`: 指向队头元素的位置
|
||||
> - `rear指针`: 指向队尾元素的位置
|
||||
|
||||
队列顺序存储类型:
|
||||
|
||||
```C++
|
||||
// 队列最大存储元素个数
|
||||
#define MaxSize 50
|
||||
|
||||
// 结构体定义
|
||||
typedef struct {
|
||||
// 存放队列元素
|
||||
ElemType data[MaxSize];
|
||||
// 队头指针和队尾指针
|
||||
int front,rear;
|
||||
} SqQueue;
|
||||
```
|
||||
|
||||
|
||||
假定:
|
||||
|
||||
- 队头指针指向队头元素
|
||||
- 队尾指针指向队尾元素的下一个位置
|
||||
|
||||
则:
|
||||
|
||||
- 初始状态(**队空条件**):`Q.front`===`Q.rear`===0
|
||||
- 入队操作:队不满时,先赋值给队尾元素,再移动队尾指针+1
|
||||
- 出队操作: 队不空时,先取队头元素值,再移动队头指针+1
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
在空队列中,初始状态为`Q.front===Q.rear==0`,当元素a入队时,队尾指针rear后移+1,入队成功后,`Q.front==0`、`Q.rear==1`,在队不满的情况下进队,都是`先赋值给队尾元素,再移动队尾指针rear+1`,通过上面的图宝贝可以看到,队列被元素打满的时:
|
||||
|
||||
- 在这个进队的过程中,没有元素出队,队头指针并没有做改变,`Q.front==0`
|
||||
- 进队操作直接影响队尾指针的变化,队列满的时候`Q.rear==Maxsize`
|
||||
|
||||
> Tips: MaxSize为队列结构体定义中,最大存储元素个数哦~
|
||||
|
||||
|
||||

|
||||
|
||||
进队说完了,那给宝贝来说说出队吧。以上图为例,队列中`Q.rear==Maxsize`、`Q.front==0`;当出现元素在队首出队,就会直接影响队首指针,从上面的流程上看:
|
||||
|
||||
- 元素出队,front指针后移+1,在队不空的情况下,操作为:`先取队头元素值,再移动队头指针+1`
|
||||
|
||||
- 当队列中的元素都陆续出队,抛弃了宝贝(都是渣男,噗呲,哈哈哈),指针会是:`Q.rear==Q.front==MaxSize`
|
||||
|
||||
|
||||
|
||||
从上面两张图中,我们来思考:
|
||||
|
||||
> 前面队空条件为:`Q.front===Q.rear===0`,那能用`Q.rear==MaxSize`来表示队满嘛?
|
||||
|
||||
|
||||
傻瓜,你在瞅瞅前面的图,明显存在`Q.rear==MaxSize`,但队列确实空的情况呀。队满要灵活判断,可不要死记书上总结的。书上说的很多结论都是有前提的,老师记结论不记前提容易张冠李戴、含糊不清的呀~
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
很显然,也存在下面这种情况:
|
||||
|
||||
- 队头指针指向队头元素的前一个位置
|
||||
- 队尾指针指向队尾元素
|
||||
|
||||
此时的入队、出队过程就宝贝自己去画流程图咯
|
||||
|
||||
|
||||
|
||||
### 循环队列
|
||||
|
||||
在上面的顺序队列中,当队满后进行出队列,由于顺序队列出队只在队首进行操作,并且只会修改队首指针,这时候就会出现队尾指针一直`Q.rear===MaxSize`情况,就如下:
|
||||
|
||||
|
||||

|
||||
|
||||
可以很明显的看到,明明队列不满,但是由于进队列只能在队尾操作,因此不能进行进队操作;通常在这种情况下入队就会出现“上溢出”。
|
||||
|
||||
> 需要明确的是:上溢出并不是真正的溢出,只是表明在顺序队列中队不满却无法入队的情况,是一种假的”溢出“
|
||||
|
||||
|
||||
|
||||
|
||||
这种情况在顺序队列中是非常常见的,也是顺序队列的一大缺点。为了克服这个缺点,计算机先贤们总是能够有很多很好的办法,这里不得不佩服!!,所以就有了循环队列,**一个将顺序队列臆想为一个环状的空间**
|
||||
|
||||
|
||||
> 很多时候就是这样,为了解决一个问题,从而衍生出一个新的知识
|
||||
|
||||
|
||||
`循环队列`:把顺序队列臆想为一个环状的空间,将存储队列元素的表从逻辑上看做为一个环
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
当队首指针`Q.front=MaxSize-1`后,再有元素`出队`就前进一个位置自动到位置0了【注意:可以结合时钟来理解,一圈转完了】
|
||||
|
||||
|
||||
- 初始时:`Q.front=Q.rear=0`
|
||||
- 队首指针进1: `Q.front=(Q.front+1)%MaxSize`
|
||||
- 队尾指针进1: `Q.rear=(Q.rear+1)%MaxSize`
|
||||
- 队列长度: `(Q.rear+MaxSize-Q.front)%MaxSize`
|
||||
|
||||
|
||||
> 是不是理解起来有点抽象,其实我最开始学到这里的时候,也不明白为什么要用`除法取余运算(%)`来实现。后来我看看了手机上的时钟指针,一圈两圈三圈的转,好像就开始悟了...其实这种取余操作在计算机知识体系中还是非常常见的,例如:组成原理中将会学到的补码,据说idea就是来源于时钟..
|
||||
|
||||
|
||||
**和时钟一样,顺时钟进行时间变换,在出队、入队时,队首、队尾指针都是按顺时针方向进1**
|
||||
|
||||
|
||||

|
||||
|
||||
如上图,循环队列从最开始初始化为空队列时:`Q.front==Q.rear==0`,经过元素a入队,队尾指针顺时针前移`Q.rear+1`,到元素a、b、c、d陆续入队,就好像时钟转完了一圈,循环队列已满,此时发现:`Q.front==Q.rear==0`在队满时候依然成立,所以结合前面提到的初始化对空条件:`Q.front==Q.rear==0`,用`Q.front==Q.rear`来区分`队空`和`队满`是非常不合适的。
|
||||
|
||||
|
||||
|
||||
|
||||
#### 如何区别队空还是队满
|
||||
|
||||
> 为了很好的区别循环队列的`队空`还是`队满`的情况,一般有三种处理方式.
|
||||
##### 牺牲一个单元来区分队空和队满
|
||||
|
||||
这种方式**要求在入队时少用一个队列单元**,是一种比较普遍的做法。约定:
|
||||
|
||||
**队头指针在队尾指针在队尾指针的下一个位置作为队满标志【重要】**
|
||||
|
||||
- 队满条件:`(Q.rear+1)%MaxSize==Q.front`
|
||||
- 队空条件:`Q.front==Q.rear`
|
||||
- 队列中元素个数:`(Q.rear+MaxSize-Q.front)%MaxSize`
|
||||
|
||||
|
||||
##### 类型中增设表示元素个数的数据成员
|
||||
|
||||
这种就很直接了,直接和MaxSize去比较,就可以有:
|
||||
|
||||
- 队空条件: `Q.count=0`
|
||||
- 队满条件: `Q.count=MaxSize`
|
||||
|
||||
|
||||
值的注意的是:在这个前提下,不论是`队空`还是`队满`,对会存在`Q.front=Q.rear`,这个可以通过前面方案解决。
|
||||
|
||||
##### 类型中增设tag数据成员标记
|
||||
|
||||
通过添加tag标记的方式,区分`队空`还是`队满`
|
||||
|
||||
- `tag==0`的情况下,如果因为删除导致`Q.front==Q.rear`,则队空;
|
||||
- `tag==1`的情况下,如果因为插入导致`Q.front==Q.rear`,则队满;
|
||||
|
||||
可能你会对上面的这两种情况有迷惑,说实话我第一次看的时候,也挺迷惑的,这里我按照我的理解来解释一下:
|
||||
|
||||
> 在循环队列中增加tag数据成员标记,tag的主要作用:
|
||||
> - 在有元素入队的时候,设置tag=1
|
||||
> - 在有元素出队的时候,设置tag=0
|
||||
|
||||
|
||||
对应的算法实现:
|
||||
```C++
|
||||
// 入队算法
|
||||
// 尾插法:Q.data[Q.rear]=x;Q.rear=(Q.rear+1)%Maxsize;Q.tag=1
|
||||
// 队空条件:Q.front== Q.rear且Q.tag==0
|
||||
int EnLoopQueue(SqQueue &Q, ElemType x){
|
||||
if(Q.front==Q.rear&&Q.tag==1){
|
||||
return 0;
|
||||
}
|
||||
Q.data[Q.rear]=x;
|
||||
Q.rear=(Q.rear+1)%MaxSize;
|
||||
Q.tag=1;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 出队算法
|
||||
// 头结点删除:x=Q.data[Q.front];Q.front=(Q.front +1)%Maxsize;Q.tag=0
|
||||
// 队满条件:Q.front == Q.rear且Q.tag=1
|
||||
// 注意:当删除之后链表为空时,还需增加一步,将尾指针指向头结点
|
||||
int DeLoopQueue(SqQueue &Q, ElemType &x){
|
||||
if (Q.front==Q.rear&&Q.tag==0){
|
||||
return 0;
|
||||
}
|
||||
x=Q.data[Q.front];
|
||||
Q.front=(Q.front+1)%MaxSize;
|
||||
Q.tag=0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
```
|
||||
#####
|
||||
|
||||
|
||||
### 代码实现
|
||||
|
||||
|
||||
#### 初始化空队列
|
||||
|
||||
|
||||
```C++
|
||||
/*
|
||||
* @Description: 循环队列初始化,队列为空
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2019-09-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 22:15:06
|
||||
*/
|
||||
void InitLoopQueque(&Q){
|
||||
Q.front=Q.rear=0;
|
||||
}
|
||||
```
|
||||
|
||||
#### 队列是否为空
|
||||
|
||||
```C++
|
||||
/*
|
||||
* @Description: 判断循环队列是否为空
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2019-09-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 22:15:06
|
||||
*/
|
||||
bool isEmpatyLoopQueue(Q){
|
||||
// 注意循环队列对空条件:Q.rear=Q.front
|
||||
if(Q.rear=Q.front){
|
||||
// 队空
|
||||
return true;
|
||||
}else{
|
||||
// 非空
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 入队操作
|
||||
|
||||
```C++
|
||||
/*
|
||||
* @Description: 循环队列元素入队
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2019-09-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 22:15:06
|
||||
*/
|
||||
bool EnLoopQueue(SqQueue &Q, ElemType x){
|
||||
// 判断循环队列是否已满 注意判断条件:(Q.rear+1)%MaxSize===Q.front
|
||||
if((Q.rear+1)%MaxSize===Q.front){
|
||||
// 循环队列满
|
||||
return false;
|
||||
}
|
||||
// 队列未满,可进行入队操作【队尾进行】
|
||||
|
||||
// 队尾指针指向的数据域进行赋值
|
||||
Q.data[Q.rear]=x;
|
||||
|
||||
//队尾指针后移+1【类似时钟的顺时针方向】
|
||||
Q.rear=((Q.rear+1)%MaxSize);
|
||||
|
||||
// 入队成功,返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### 出队操作
|
||||
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 循环队列元素出队
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2019-09-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 20:32:18
|
||||
*/
|
||||
bool DeLoopQueue(SqQueue &Q, ElemType &x){
|
||||
|
||||
// 判断循环队列是否为空队列
|
||||
if(Q.rear==Q.front){
|
||||
|
||||
// 队列为空,无法进行出队操作,返回false
|
||||
return false;
|
||||
}
|
||||
|
||||
// 循环队列非空,元素可出队【队首操作】
|
||||
|
||||
// 将循环队列队首指针指向的元素的数据域赋值给变量x
|
||||
x=Q.data[Q.front];
|
||||
|
||||
// 移动队首指针,顺时针后移+1
|
||||
Q.front=(Q.front+1)%MaxSize;
|
||||
|
||||
// 出队成功,返回true
|
||||
return true;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
#### 获取队头元素
|
||||
|
||||
```C++
|
||||
/*
|
||||
* @Description: 获取循环队列队头元素
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2019-09-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-18 20:15:33
|
||||
*/
|
||||
bool GetLoopQueueHead(SqQueue &Q, ElemType &x){
|
||||
// 判断循环队列是否为空队列
|
||||
if(Q.front==Q.rear){
|
||||
// 队列为空,没有队头元素,返回false
|
||||
return false;
|
||||
}else{
|
||||
// 获取队头指针指向元素的数据域,赋值给x
|
||||
x=Q.data[Q.front];
|
||||
|
||||
// 获取队头元素成功,返回true
|
||||
return true;
|
||||
}
|
||||
}
|
||||
```
|
||||
240
docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md
Normal file
@@ -0,0 +1,240 @@
|
||||
<!--
|
||||
* @Description: 队列的链式存储结构
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-19 08:22:39
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-20 16:10:16
|
||||
-->
|
||||
|
||||
|
||||
# 队列的链式存储结构
|
||||
|
||||
`链队列`:和顺序队列一样,基于队列的链式表示叫做`链队列`,实际上为:**一个同时带有队头指针和队尾指针的单链表**
|
||||
|
||||
- 头指针指向队头结点
|
||||
- 尾指针指向队尾结点(单链表的最后一个结点)
|
||||
|
||||
|
||||
这里复习下顺序队列的定义,进行比较学习
|
||||
|
||||
> 队列的顺序实现是指分配一块连续的存储单元用来存放队列中的元素,并且附加两个指针。
|
||||
> - 队头指针指向队头元素
|
||||
> - 队尾指针指向队尾元素的下一个位置
|
||||
|
||||

|
||||
|
||||
|
||||
队列的链式存储结构:
|
||||
|
||||
|
||||
```C++
|
||||
// 链式队列节点定义
|
||||
typedef struct{
|
||||
// 结果点数据域
|
||||
ElemType data;
|
||||
// 结点指针域
|
||||
struct LinkNode *next;
|
||||
}LinkNode;
|
||||
|
||||
// 链式队列定义
|
||||
typedef struct{
|
||||
// front 队头指针,rear 队尾指针
|
||||
LinkNode *front,*rear;
|
||||
}LinkQueue;
|
||||
|
||||
```
|
||||
|
||||
结合上面的`不带头结点`链式队列结构图,假设存在链式队列<LinkQueue,linkQueue>
|
||||
|
||||
- 队空: `linkQueue.front==NULL`且`linkQueue.rear==NULL`
|
||||
- 出队: 先判断队列是否为空,非空队列则取出队头元素,从链表中闪出去,`队头指针Q.front指向下一个结点`,如果出队的结此为尾结点,出队后队空,需要将Q.front和Q.rear都置为NULL
|
||||
- 入队: 建立一个新的结点,将新的结点插入到链表的尾部,修改队尾指针Q.rear指向新插入的结点。如果原队列为空,需要将队首指针也指向该结点
|
||||
|
||||
仔细思考上面的入队、出队操作,都需要考虑队空的情况下的特殊处理,不带头结点的队列导致队空队首和队尾指针都为NULL,比较麻烦;结合之前整理、学习过的单链表,套用一下先贤的思路,也整上一个头结点,就会发现容易处理很多;
|
||||
|
||||

|
||||
|
||||
链式队列加上头结点后,之前较为复杂的入队、出队操作就统一起来了。
|
||||
|
||||
- 队空:`Q.front==Q.rear`,都指向头结点,一般数据域可以为空
|
||||
- 出队:判断队列是否为空,队列非空则在队首移动指针,将队首指针指向下一个元素。如果队列中就一个元素,则出队后将成为空队,`Q.rear==Q.front`,最后释放元素内存空间。
|
||||
- 入队:将元素插入队尾,移动队尾指针,即便为空队列入队,由于队列带有头结点,此时就很好的避免操作队首指针了。
|
||||
|
||||
|
||||
特别注意:
|
||||
|
||||
- 用单链表表示的链式队列非常适合频繁出队、入队、元素变化大的场景
|
||||
- 不存在队满情况,也不会出现溢出情况;
|
||||
- 链式队列不会出现存储分配不合理、“溢出”的情况,内存动态分配
|
||||
|
||||
### 基本操作
|
||||
|
||||
> Tips: 基于带头结点链式队列的基础操作
|
||||
|
||||
#### 队列初始化
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 链式队列初始化
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-06-27 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-02-18 22:15:06
|
||||
*/
|
||||
voide InitLinkQueue(LinkQueue &Q){
|
||||
|
||||
// 创建头结点
|
||||
Q.front=Q.rear=(LinkNode*)malloc(sizeof (LinkNode));
|
||||
|
||||
// 头结点的指针域指向的下一个结点为空
|
||||
Q.front->next=NULL;
|
||||
}
|
||||
```
|
||||
|
||||
注意这个初始化操作,我第一次看的时候,非常不理解为什么在队首指针和队尾指针都指向已经创建好的头结点后,突然写一行`Q.front->next=NULL;`,后来的的理解是:
|
||||
|
||||
> 链式队列,本质是基于单链表的队列,那带头结点的链式队列,其实强调的也就是单链表要带头结点。队列的队首指针和队尾指针确定指向单表的队首和队尾就ok;初始化的时候,带头结点的单链表实质就只有一个头结点。而此时的链式队列,需要将队首指针和队尾指针指向单链表的头结点就行,好像到这里就完了。但是这样却忽视了单链表,只是注重的队列的front和rear指针。单链表的结点元素是分数据域和指针域的,即便是头结点的数据域可以不存什么(当然也常会存一些链表信息什么的),此处的`Q.front->next=NULL`就是用来处理链表的头结点的指针域的,让其指向下一个单链表元素为空,这里是非常需要处理的,非常细节!
|
||||
|
||||
#### 判断队空
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 判断链式队列是否为空
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-06-27 14:24:22
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-02-16 22:15:06
|
||||
*/
|
||||
bool IsEmptyLinkQueue(LinkQueue Q){
|
||||
if(Q.front==Q.rear){
|
||||
// 队首、队尾指针指向同一个结点内存地址,队空
|
||||
return true;
|
||||
}else{
|
||||
// 非空
|
||||
return false;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
#### 入队
|
||||
|
||||
|
||||
```C++
|
||||
/*
|
||||
* @Description: 链式队列入队操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-06-46 14:17:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-02-18 22:15:06
|
||||
*/
|
||||
void EnLinkQueue(LinkQueue &Q, ElemType x){
|
||||
|
||||
//创建入队结点元素
|
||||
node=(LinkNode *)malloc(sizeof(LinkNode));
|
||||
|
||||
// 赋值给结点数据域
|
||||
node->data=x;
|
||||
// 单链表中结点的指针指向下一个元素,为空
|
||||
node->next=NULL;
|
||||
|
||||
// 队尾进队,将结点node和队尾结点链接起来,确保不断链
|
||||
Q.rear->next=node;
|
||||
// 修改队尾指针,指向新入队的结点node
|
||||
Q.rear=node;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
#### 出队
|
||||
|
||||
```C++
|
||||
|
||||
/*
|
||||
* @Description: 链式队列出队操作
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2020-05-18 11:25:28
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-02-22 06:15:06
|
||||
*/
|
||||
bool DeLinkQueue(LinkQueue &Q, ElemType &x){
|
||||
|
||||
// 判断队列是否为空
|
||||
if(Q.front==Q.rear){
|
||||
// 队列为空,没有元素出队
|
||||
return false;
|
||||
}
|
||||
|
||||
// Q.front指向单链表的头结点,出队需要出单链表的除头结点外的第一个结点(头结点的下一个结点:Q.front->next)
|
||||
temp=Q.front->next;
|
||||
|
||||
// 变量x赋值
|
||||
x=temp->data;
|
||||
|
||||
// 修改单例表的头指针,指向链表中待删除元素的下一个元素
|
||||
Q.front->next=temp->next;
|
||||
|
||||
// 队尾指针和队首指针的下一个结点重合,表示当前链式队列只有一个元素,删除后,队列为空
|
||||
if(Q.rear==temp){
|
||||
// 链表中队首、队尾指针重合,队列为空
|
||||
Q.rear=Q.front;
|
||||
}
|
||||
|
||||
// 释放删除元素的内存空间,注意,这里释放的是头结点的下一个结点
|
||||
free(temp);
|
||||
|
||||
// 出队成功
|
||||
return true;
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
出队的时候明显有些绕,需要明确队列中头结点的存在,出队出的是单链表中头结点的后一个结点,同时要确保整个过程`不断链`
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
### 双端队列
|
||||
|
||||
`双端队列`: 允许在两端都可以进行入队和出队操作的队列,元素的逻辑结构仍然是线性结构
|
||||
|
||||

|
||||
|
||||
**双端队列的两端分别称为`前端`和`后端`,两端都可以`入队`和`出队`**
|
||||
|
||||
- 进队:前端进的元素排列在队列中后端进的元素的前面,后端进的元素排列在队列前端进的元素后面;
|
||||
- 出队:无论是前端还是后端出队,先出的的元素排列在后出的元素的前面
|
||||
|
||||
|
||||
在双端队列的基础上,还衍生出:
|
||||
|
||||
- `输入受限的双端队列`:允许在一端进行插入和删除操作,但在另外一端只允许进行删除的双端队列
|
||||
- `输出受限的双端队列`:允许在一端进行插入和删除曹组,但在另外一端只允许进行插入的双端队列
|
||||
|
||||
|
||||
当然,如果`限定双端队列从某个断点插入的元素只能从该端点删除`,那么此时的双端队列就演变为两个栈底相邻的栈了。
|
||||
|
||||
|
||||
|
||||
|
||||
### 队列的补充
|
||||
|
||||
- 最适合用来链队的链表是:`带队首指针和队尾指针的非循环单链表`
|
||||
|
||||
- 栈和队列的逻辑结构都是线性表,存储结构可能是顺序的(顺序栈、顺序队列),也可能是链式的(链栈、链队)
|
||||
- 不论是顺序存储还是链式存储,**栈和队列都只能进行顺序存取(本质是线性表)**。数组是可以做到随机存取(本质是顺序表)
|
||||
- 队列先进先出的特性:`先进队列的元素先出队列,后进队列的元素后出队列`
|
||||
|
||||
|
||||
特别注意:
|
||||
|
||||
队列用链表形式存储时,删除元素,需要从队头删除,一般情况下,仅仅修改头指针,但是如果此时队列中
|
||||
仅有一个元素,则尾指针也是需要被修改的。**因为队列中只有一个元素时,删除后队列为空,需要修改尾指针为:`rear=front`**
|
||||
138
docs/manuscripts/ds/栈和队列/7.栈和队列的应用.md
Normal file
@@ -0,0 +1,138 @@
|
||||
<!--
|
||||
* @Description: 栈和队列的应用
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-14 21:48:49
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-14 21:49:02
|
||||
-->
|
||||
|
||||
|
||||
|
||||
|
||||
# 栈和队列的应用
|
||||
|
||||
> Tips: 这里不会做过多文字介绍相关应用,具体需要自己看书、查资料揣摩
|
||||
|
||||
### 栈的应用
|
||||
|
||||
- 括号匹配
|
||||
- 表达式求值
|
||||
> 表达式求值是程序设计语言编译中一个最基本的问题,类似有前缀、中缀、后缀表达式转换等典型问题。
|
||||
- 递归
|
||||
|
||||
这里重点总结下递归,递归非常重要,是一种很经典的程序设计方法
|
||||
|
||||
> 递归的简单定义: 如果在一个函数、过程或数据结构的定义中又应用了自身,那么这个函数、过程或者数据结构称为递归定义的,简称递归。
|
||||
|
||||
|
||||
|
||||
递归通常把一个大型的复杂问题,层层转化为一个与原问题相似的规模较小的问题来求解。
|
||||
|
||||
**递归策略只需要少量的代码就可以描述出解题过程所需要的多次重复的计算,很大程度上减少了程序的代码量,当时通常情况下,递归的效率并不是很高**
|
||||
|
||||
|
||||
经典的斐波拉切数列,可以用递归来实现:
|
||||
|
||||
|
||||
```C++
|
||||
|
||||
// 定义递归函数,实现斐波拉切数列
|
||||
|
||||
int Fibonacci(n){
|
||||
if(n==0){
|
||||
return 0;
|
||||
}else if(n==1){
|
||||
return 1;
|
||||
}else{
|
||||
// 调用Fibonacci函数,进行递归
|
||||
return Fibonacci(n-1)+Fib(n-2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
```
|
||||
|
||||
上面很基础的代码,是分`n=0`和`n=1`的情况,先进行过滤,其他情况下则进行递归,其实在日常开发中,经常会有简化的函数封装
|
||||
|
||||
|
||||
```C++
|
||||
|
||||
// 定义递归函数,实现斐波拉切数列
|
||||
|
||||
int Fibonacci(n){
|
||||
if(n<2){
|
||||
return n;
|
||||
}else{
|
||||
// 调用Fibonacci函数,进行递归
|
||||
return Fibonacci(n-1)+Fib(n-2);
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
上面的简化,则需要程序考虑变量n是整数。
|
||||
|
||||
当然,前面有说道:**通常情况下,递归的效率并不搞**,主要原因就是递归通过返回调用自己本身,导致往往时间复杂度较高。
|
||||
|
||||
可以采用空间换时间的思路,来降低算法的时间复杂度
|
||||
|
||||
```C++
|
||||
// 使用非递归实现
|
||||
int Fibonacci(int n) {
|
||||
if(n < 2)
|
||||
return n;
|
||||
int f = 0, g = 1;
|
||||
int result = 0;
|
||||
|
||||
// 迭代
|
||||
for(int i = 1; i < n; i++){
|
||||
result = f + g;
|
||||
f = g;
|
||||
g = result;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// 利用数组,空间换时间
|
||||
int Fibonacci(n){
|
||||
// 注意溢出
|
||||
int arr[100]={0,1,1}
|
||||
|
||||
// 叠加,结果存放在数组中
|
||||
for(let i=3;i<=n;i++){
|
||||
arr[i]=arr[i-1]+arr[i-2]
|
||||
}
|
||||
return arr[n]
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
|
||||
必须注意递归模型不能是循环定义的,满足条件:
|
||||
|
||||
- 递归表达式(递归体)
|
||||
- 边界条件(递归出口),即:算法结束条件
|
||||
|
||||
|
||||
递归的精髓在于是否能够将原来的问题转化为属性相同但规模较小的问题。有点类似实现目标过程中,将大目标转化为小目标(1亿....)来解决,噗呲啊哈哈哈
|
||||
|
||||
**递归次数过多容易造成栈溢出,效率不高的主要原因是递归调用过程中包含很多重复的计算**
|
||||
|
||||
|
||||
### 队列的应用
|
||||
|
||||
- 层次遍历
|
||||
|
||||
> 例如:二叉树的遍历
|
||||
|
||||
- 计算机系统
|
||||
|
||||
|
||||
队列在计算机系统中的应用非常广泛,作用:
|
||||
|
||||
- 解决主机和外部设备之间速度不匹配的问题(例如:内存和打印机)
|
||||
- 解决由多用户引起的资源竞争问题(例如:操作系统中的进程调度...)
|
||||
|
||||
|
||||
其实,队列在计算机系统的中应用, 在看完操作系统那本书后,就会很好理解,建议学到这里,也去翻翻操作系统,汤晓丹那本很经典哟...
|
||||
67
docs/manuscripts/ds/栈和队列/8.特殊矩阵的压缩存储.md
Normal file
@@ -0,0 +1,67 @@
|
||||
<!--
|
||||
* @Description: 特殊矩阵的压缩存储
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-20 16:18:51
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-20 17:04:44
|
||||
-->
|
||||
|
||||
|
||||
# 特殊矩阵的压缩存储
|
||||
|
||||
> 这部分知识我个人觉得以了解为主,复习、学习的时候还是要以前面的部分为主!
|
||||
|
||||
矩阵在`计算机图形学`、`工程计算`中占有举足轻重的地位。
|
||||
|
||||
|
||||
### 数组的定义
|
||||
|
||||
`数组`: 由n(n≥1)个相同类型的数据元素构成的有限序列。
|
||||
|
||||
每个数据元素称为一个数组元素,同时每个元素受n个线性关系的约束,**每个元素在n个线性关系中的序号称为元素的`下标`**,称为该数组为n的数组。
|
||||
|
||||
数组和线性表的关系:
|
||||
- 数组是线性表的推广。
|
||||
- 数组一旦被定义,维数和维界就不再改变。
|
||||
- 除了结构的初始化和销毁外,数组只会有存取元素和修改元素的操作。
|
||||
|
||||
|
||||
一维数组可以看做是一个线性表
|
||||
|
||||
二维数组可以看做元素是线性表的线性表
|
||||
|
||||
....
|
||||
|
||||
|
||||
### 矩阵的压缩存储
|
||||
|
||||
|
||||
`压缩存储`:多个值相同的元素只分配一个存储空间,对零元素不分配存储空间---->节省存储空间。
|
||||
|
||||
`特殊矩阵`:具有很多相同矩阵元素或零元素,并且这些相同矩阵元素或零元素的分布有一定规律性的矩阵。
|
||||
|
||||
- 对称矩阵
|
||||
- 上、下三角矩阵
|
||||
- 对角矩阵(带状矩阵)
|
||||
- ....
|
||||
|
||||
这里如果学过线性代数这本书,其实也就很好理解(赶紧去把数学知识捡起来鸭,噗呲哈哈啊哈)
|
||||
|
||||
`稀疏矩阵`:矩阵元素个数s相对于矩阵中非零元素的个数t来说非常多、差距非常大,即`s>>t的矩阵`可以叫`稀疏矩阵`
|
||||
|
||||
|
||||
注意:
|
||||
|
||||
- 常规方法来存储稀疏矩阵,会想当浪费存储空间,所以稀疏矩阵只需要存储非零元素
|
||||
- 通常非零元素的分布是没有规律的,除了存储非零元素外,还需要存储元素所在位置的行和列
|
||||
- 寻相互存储三元组 `<行标,列表,值>`
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
三元组的结点存储了行标(row)、列表(col)、值(value)三种信息,是主要用来存储稀疏矩阵的一种数据结构。
|
||||
|
||||
|
||||
**注意:矩阵压缩存储的目的就是为了节省空间,已经存过的就不存或者少存(经典想法)**
|
||||
BIN
docs/manuscripts/ds/栈和队列/images/不带头结点的链式队列.png
Normal file
|
After Width: | Height: | Size: 18 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/入队.png
Normal file
|
After Width: | Height: | Size: 36 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/出队.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/双端队列.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/带头结点的链式队列.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/循环队列入队.png
Normal file
|
After Width: | Height: | Size: 54 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/循环队列初始化.png
Normal file
|
After Width: | Height: | Size: 22 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/栈的基本结构.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/栈的链式存储结构.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/稀疏矩阵的存储变换.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/链式队列出队.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/队列的基本结构.png
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/队列队满情况分析.png
Normal file
|
After Width: | Height: | Size: 23 KiB |
BIN
docs/manuscripts/ds/栈和队列/images/顺序栈共享存储空间.png
Normal file
|
After Width: | Height: | Size: 19 KiB |
24
docs/manuscripts/ds/栈和队列/readme.md
Normal file
@@ -0,0 +1,24 @@
|
||||
<!--
|
||||
* @Description: 数据结构-栈和队列
|
||||
* @Version: Beta1.0
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-22 08:02:29
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-22 08:02:43
|
||||
-->
|
||||
|
||||
|
||||
# 栈和队列
|
||||
|
||||
### 主要内容
|
||||
|
||||
- [栈的基本概念和基本操作](1.栈的基本概念和基本操作.md)
|
||||
- [栈的顺序存储结构](2.栈的顺序存储结构.md)
|
||||
- [栈的链式存储结构](3.栈的链式存储结构.md)
|
||||
- [队列的基本概念和基础操作](4.队列的基本概念和基础操作.md)
|
||||
- [队列的顺序存储](5.队列的顺序存储结构.md)
|
||||
- [队列的链式存储](6.队列的链式存储结构.md)
|
||||
- [栈和队列的应用](7.栈和队列的应用.md)
|
||||
- [特殊矩阵的压缩存储](8.特殊矩阵的压缩存储.md)
|
||||
|
||||

|
||||
BIN
docs/manuscripts/ds/栈和队列/栈和队列_水印.png
Normal file
|
After Width: | Height: | Size: 1.5 MiB |
2
docs/manuscripts/note-map/cn-map.md
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
# 计算机网络思维导图
|
||||
3
docs/manuscripts/os/readme.md
Normal file
@@ -0,0 +1,3 @@
|
||||
|
||||
# 操作系统
|
||||
doing
|
||||
215
docs/manuscripts/wechat-list.md
Normal file
@@ -0,0 +1,215 @@
|
||||
|
||||
# 公众号汇总
|
||||
|
||||
### 2020年
|
||||
|
||||
|
||||
#### 7月
|
||||
|
||||
|
||||
- [【2020-07-26】微信公众号我来了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483659&idx=1&sn=ac7b633a45ac06d388e0698163a2543e&chksm=fcdfb887cba8319151aedfa80c5b59d130838af81fe51c76e5c4926f82f4937b51c8c0c1470e&token=1304241434&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-07-27】介绍一下,我在B站](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483760&idx=1&sn=30a9fa2a051079c5330039615950c34d&chksm=fcdfb8fccba831ea64644be501ecca3cea5846f16367faed9c84b44a30d9b6dc30456dae6548&token=1304241434&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-07-28】五年了,我终于换了人生中的第一台MacBookPro](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483762&idx=1&sn=e9ea759f1c1589881cc3bd9cabddb70a&chksm=fcdfb8fecba831e8c4635a4cefd302977071ed11a4dda6161cf9ad8458865297194f87cb013a&token=1304241434&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-07-29】工作中第一次被喷,我到底是如何应对的?](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483770&idx=1&sn=6b760873a814f4e18baab415bee3d863&chksm=fcdfb8f6cba831e00802de653ff6723a0bb169a93fe3a6a9762ee62d75d8cd88409268db9047&token=1304241434&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-07-31】CSDN关注100了,就这????](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483778&idx=1&sn=3d9f623c58d595f75d7092783a6c5abe&chksm=fcdfb80ecba83118e76de1ed88a5be51229e4145182aee6e0bcc13e4697707cf9f4609d8799d&token=1304241434&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
|
||||
#### 8月
|
||||
|
||||
- [【2020-08-01】旧友相见,甚是怀念](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483790&idx=1&sn=76e13ac79ad498309542c9f41878bb1c&chksm=fcdfb802cba8311456ea9ff3309c4354055022cd0056b13c11fac44252231550e17a03f26f29&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-08-03】JavaScript基础介绍和快速入门](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247483805&idx=1&sn=4da4e0d3a2912aee146248c1d8f7f96f&chksm=fcdfb811cba83107fd8f08d3e35af7c72bf7d908d577ad83e45d80b0e9d1bbdbf16b1f169d64&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
#### 9月
|
||||
|
||||
|
||||
- [【2020-09-01】Redis的简单安装和部署 ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484600&idx=1&sn=489aa1bd12487b0bf8f2a7694f4ca1aa&chksm=fcdfbd34cba83422f0afee027747d9e95773e093fa3a24225c2729029c4392bf42043964782f&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-01】就很像?? ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484600&idx=2&sn=a9962c6ca3a5eddd085bcd15617f64d9&chksm=fcdfbd34cba83422b987020a858b7cf31bfde6033642d697d5a00ad9ed618f3cf14deb207d67&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-03】shell编程基础整理 ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484702&idx=1&sn=6e3e862153755d9e61f5f4ebf220381d&chksm=fcdfbc92cba835844e8b6fd37d86a34ccf83342895f448c88ba5b62db974eb536a8e74a121aa&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-03】大学四年建站用过的云服务器都在这里了 ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484702&idx=2&sn=c7589eecbe58ff8939f72c0ff0bf567d&chksm=fcdfbc92cba83584b03dfeea7290606ce8249b0c3105b0b3b95a9087c77e3b1c7f863d8e30f9&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-04】面试复盘和思考 ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484711&idx=1&sn=bf362439ccfad04da53ce65c824a988d&chksm=fcdfbcabcba835bddc43c40fd3a454793adf7849a5d5bb356825d481b82ae3e58a749859502c&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-06】朋友是“无用”的,不是你瞧不起我,就是我瞧不起你 ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484759&idx=1&sn=e0f8a7a70ddede75d94b202ddc6106d6&chksm=fcdfbcdbcba835cd2138658d750f7e09a820b34daf4624f253a21a11b5de56635d35e4c0df19&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-06】GitHub简单使用 ](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484759&idx=2&sn=ade86739c94f99f944a3d387bc7e13ef&chksm=fcdfbcdbcba835cd192c3b7b7eeea8f5dbb16b2b2fa58b6e2094184f5aa3341927a6d1fad6f8&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-07】MySQL日志类型把我难哭了,你学废了吗?](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484771&idx=1&sn=6ae4c6e8d333b0e1aa5cd1aee161d9b8&chksm=fcdfbcefcba835f94e3c0abc189477f241f675f38a63eb03bd320447e89da39cb08b72038ba3&token=1613702159&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-11】向各位汇报这周状态,再也不敢鸽了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484783&idx=1&sn=b9e82a2c2b04b7050d0659085af537ef&chksm=fcdfbce3cba835f5e692f5ffbb16505dbf3b5ccc9bb0bdf4b3f467629b293d0e0ce3086ec8dc&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-11】向各位汇报这周状态,再也不敢鸽了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484783&idx=1&sn=b9e82a2c2b04b7050d0659085af537ef&chksm=fcdfbce3cba835f5e692f5ffbb16505dbf3b5ccc9bb0bdf4b3f467629b293d0e0ce3086ec8dc&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-12】向各位汇报,再也不敢鸽了,人生处处有惊喜](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484784&idx=1&sn=ae73f1f4e53b622039a75ec41cabe378&chksm=fcdfbcfccba835eafefe304913e4078cf8dfac22f62fd9d686b307bbdf46d147016f5e876e05&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-13】来来来,无厘头技术(水)文,各种尬。简简单单评价一下](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484815&idx=1&sn=10d26a600112ec4f95b3b3f470955744&chksm=fcdfbc03cba83515b07f0ae6cee791d1fb5fd619364cff3a17a4deab91333f0a6277b09a66a9&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-13】基础Brew和Tree的安装实录](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484815&idx=2&sn=94a6455ed6b17fa5b27e96358e935803&chksm=fcdfbc03cba83515d13dcfc2dea2445085a34ff4360e0a367fd914bb04bc6ba18a780a0cd2d2&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-13】PM2进程管理,给我学!](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484815&idx=3&sn=38a289efffda9510b5ff04c5bed0663e&chksm=fcdfbc03cba835154c888b9d7f86eac85c250eefb9d053687173274373f2f8d7b19fc307e76a&token=639111151&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-14】数据结构,一定要学废了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484823&idx=1&sn=d41bb8da02585cf9ea8d0b3ef27e3dbb&chksm=fcdfbc1bcba8350d84ba2f01eaf187cbaa2d4cf5a9078beb1f2fafe94edb0126c82595ed8191&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-16】ELK基础概念与常用架构整理](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484837&idx=1&sn=7f0de3eeea3fc6ee299587704f5c44cd&chksm=fcdfbc29cba8353fd894582da7ae2c93b5920c4dbb1e197b011a817dc0962e317842a32d5560&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-17】分享书上一段话,问一个问题](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484850&idx=1&sn=7af55ef3a7d843d9c43de6d6c7911da3&chksm=fcdfbc3ecba835287b2c644cda606454a713d370fbd7d14714b22a04277f7a7784b96b8b277e&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-17】看源码遇到的三个知识点,一个也没懂](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484850&idx=2&sn=c59839c677d7c9652a09d1f8c70ef8d6&chksm=fcdfbc3ecba83528cf8271a2615129340a6f11954b6d9396160d0fb2c41593253d5e3510a031&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-20】express()函数整理](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484865&idx=2&sn=63e6b669341217135013816464dd5bd9&chksm=fcdfbc4dcba8355b4de0f712047709425a35fa3b122378b31f0e4db3afb82dfd38872862aab4&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-22】入秋了,安好](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484865&idx=1&sn=e39e3547da49f40e1b64deadf9a9cfef&chksm=fcdfbc4dcba8355bfa9c8b9531a463fc652b764064528dd6c243f47a157b20e017bad3f410f4&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-22】Nginx安装详解,我服务器上也是这样的](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484897&idx=1&sn=b1073522cfd3ce6ebbe85e85ad4e35e0&chksm=fcdfbc6dcba8357bdb212c9db1378a045d0dcfd95b79ed05688180f05d2b391f9b724d0d752f&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-09-22】被攻击的一天](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484897&idx=2&sn=34c61ed01c6522d2861be3342ec12ad5&chksm=fcdfbc6dcba8357b76eb0fe6c502d932def6cd232297b010f9b2f9a1fca35c38df77dacce7f2&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-09-26】跟父亲视频的一个半小时,聊到了我,也聊到了Ta](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484929&idx=1&sn=394783dd2bfd65da24ae6dcb89d69ec6&chksm=fcdfbf8dcba8369b926b7083bbe3515aa5857f7589acc3f9d6d4987c67539a76dbd6e3cb70a1&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
#### 10月
|
||||
|
||||
- [【2020-10-07】时间太快,溜了溜了,杭州见](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484943&idx=1&sn=ad37db87dc40f381fd18cc828e492384&chksm=fcdfbf83cba8369598fc2773b63df235a9719b43749e7daab753c621fef5af4fba054dbb46ea&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-10-14】写不了代码就不写嘛](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484951&idx=1&sn=edddf3d6c8f3fc6dd1d14063b536c732&chksm=fcdfbf9bcba8368d81ddffcbd258f7e4b7fb573d2a8963859e1b156e8a5f5d81f5629c49be6e&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-10-18】我不行了,这号关注量男女7:3 还怎么相亲嘛?](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484968&idx=1&sn=d37960ed81044fbf314440af85049d65&chksm=fcdfbfa4cba836b25082535910f7137d1513d834d54fbfadf48a433b29511ccf4d532f19b88a&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-10-26】悄悄接你下班,陪你回家](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247484988&idx=1&sn=947c487946fa3574d33e9c6861a1ee28&chksm=fcdfbfb0cba836a626d2efa904a5177c2e0916c381b26c89b6dcfc610a380b906d4480f7cc9b&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
#### 11月
|
||||
|
||||
|
||||
- [【2020-11-01】11月,你好](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485002&idx=1&sn=3760eba58f7ded433b71bec48b89a681&chksm=fcdfbfc6cba836d0b7db1f2aa5a4a884f68f8ce20a59aa44b4ac46c59eb4dd1c233079241a4a&token=368257571&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-11-15】她来了她来了,她带着剪了三遍的视频来了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485042&idx=1&sn=181ae5062c31ee7931390607b6f10358&chksm=fcdfbffecba836e8275c849007470db6964f7cd675af59fe73c94369334d17d4840e8c0413d5&token=898438314&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-11-18】陪我一路的小姐姐,谢谢啦~ 我大意了呀,没有闪](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485053&idx=1&sn=ed2fe0de87b70781cdb7755ef4726340&chksm=fcdfbff1cba836e7165dc53722aaf96ef38d8f43cfadadcb4695d8ff430ea64619caada81cfa&token=1939941957&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-11-30】11月的尾巴,12月你好](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485066&idx=1&sn=1d357917f548a6d977af96c6582db527&chksm=fcdfbf06cba836103152f7a3fdfbf97c1be2472a84f824cbddd532c15aefe14c71b3b076233f&token=831506871&lang=zh_CN#rd)
|
||||
|
||||
|
||||
#### 12月
|
||||
|
||||
|
||||
- [【2020-12-06】周末小记——忆旧友、吃火锅,也会感慨](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485080&idx=2&sn=bdc551f2e9bf54dc01881979339af8ad&chksm=fcdfbf14cba836022a05854547cbca03b5a08b912a0e0f195d4856d6b53ecd78aee2f167b515&token=1581389686&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-12-10】上火、牙疼,也要砍程序媛一刀](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485100&idx=1&sn=e7c0c41229d51ebfab2939deb1751672&chksm=fcdfbf20cba836364da35ab5acfed076876aae486126bc1c41cdd2502cc89a41cbde7c645610&token=1054397108&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2020-12-17】今晚不蹦迪,来聊一聊个人项目的接口返回](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485136&idx=1&sn=4619fb835e6d57e106ab01116012662a&chksm=fcdfbf5ccba8364aecddf14d11ed8ba36f38050b83b30b8d46e10f86b164aab05322b8455b36&token=755050934&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2020-12-20】事情,从英吉利海岸的那杯卡布奇诺美式咖啡说起](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485180&idx=1&sn=15ab9be3e15130103f26c919cbe0b605&chksm=fcdfbf70cba83666d287acc35485d02ddf67bacad6ea46d9ef04521f9f429fcb015d371c918e&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
### 2021年
|
||||
|
||||
|
||||
|
||||
#### 1月
|
||||
|
||||
|
||||
|
||||
- [【2021-01-06】谁在看小王子呀~](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485228&idx=1&sn=1c30866a209af2a5eb927fd7bd63cc8b&chksm=fcdfbea0cba837b6d4cf9865b72a6a1553c4d9b6a6cce369bb09f66730ab37ec649071e7ab7c&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-01-15】2020小结,没事就点点看看呗,反正小目标都没完成](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485249&idx=1&sn=dadf2a6dbed1879bbd98c62491436a9c&chksm=fcdfbecdcba837db5c11b8023ffa7ad6cf5a47c03027a0029604a50d0a77c75908efc05af39a&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
- [【2021-01-17】搞波大的,浅谈深拷贝——文末有彩蛋](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485258&idx=1&sn=fb71007a5feed8e18674be27b1c749ab&chksm=fcdfbec6cba837d099e90a5f45781ee8cac474388e25ad9383a4fbc05fdb16a8e1377265c018&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-01-18】到底该如何发布Npm插件,常用指令在这里](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485277&idx=1&sn=9eb7c3cef21ace2cc5853e382f2bb03f&chksm=fcdfbed1cba837c7839f3b57836f43b3425c8b5a7888f543bf4a1dd8b39cd82ed7d51a24a685&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-01-20】好用的AntDocs,也来学着用一下,基本过程整理](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485291&idx=1&sn=19f13df8131a9f662973f2d9240c1eab&chksm=fcdfbee7cba837f180d8ad30735cd61e6c73fe195e63d46046bb24f80e1536aa0a585c3e1015&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-01-27】【持续更新】从查找算法开始数据结构入门,大家都在掘金等你](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485318&idx=1&sn=6ae5fc9f1cf994818ff89d53a926761e&chksm=fcdfbe0acba8371c9d0025008084857cf14c52b01dfb1b9460d3388ba543c36da2abcbf90216&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-01-30】ORM框架入门之Sequelize,我快翻译不动了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485341&idx=1&sn=fc493c28ab138056567e916b769ddbf2&chksm=fcdfbe11cba8370793e8e0d71e7766f4e1e7f3e8672921d6b98757f7d7b271b290f3edc65d6f&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
#### 2月
|
||||
|
||||
|
||||
- [【2021-02-07】被妹妹支配的一周,晚上差点连家都回不去..](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485376&idx=1&sn=049a5df5cb97786e80aded38a1bf3732&chksm=fcdfbe4ccba8375a52cb8d7077836216e5f5f41ee9453aebf524eb0a5d8a5db48cbabc11f3e4&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-02-11】【新年快乐】程序员的2020,就这样悄咪咪地溜走了](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485404&idx=1&sn=276100858df23daf987dbc68997477df&chksm=fcdfbe50cba837460079fc9ab414754a49668f82dc0f6a5a41ec320d3e5dd77c1a8c271e061b&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
|
||||
|
||||
- [【2021-02-13】抢红包、拼手气来啦,之前答应的抽奖变成新年红包啦~](https://mp.weixin.qq.com/s?__biz=MzU3MTUxOTIwMw==&mid=2247485420&idx=1&sn=26c0e3690363af5dddd805ae417eeee9&chksm=fcdfbe60cba8377645e44333ccbe35147b9844578008e5699aba62b82c12fc03634e2d68781c&token=1356818265&lang=zh_CN#rd)
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
|
||||
## 计算机网络思维导图
|
||||
@@ -1,6 +0,0 @@
|
||||
---
|
||||
title: 操作系统
|
||||
---
|
||||
|
||||
## 操作系统
|
||||
doing
|
||||
@@ -144,13 +144,14 @@ yarn run dev
|
||||
|
||||
### 在线浏览
|
||||
|
||||
https://408.142vip.cn
|
||||
[https://408.142vip.cn](https://408.142vip.cn)
|
||||
|
||||
|
||||
网站无法访问时,建议通过科学上网访问备用网络
|
||||
|
||||
- Github: https://142vip.github.io/408CSFamily
|
||||
- Netlify: https://408-family.netlify.app
|
||||
- Vercel: https://408-family.vercel.app
|
||||
- Github: [https://142vip.github.io/408CSFamily](https://142vip.github.io/408CSFamily)
|
||||
- Netlify: [https://408-family.netlify.app](https://408-family.netlify.app)
|
||||
- Vercel: [https://408-family.vercel.app](https://408-family.vercel.app)
|
||||
|
||||
|
||||
|
||||
@@ -158,68 +159,99 @@ https://408.142vip.cn
|
||||
### 提交记录
|
||||
|
||||
|
||||
---
|
||||
## 赞赏列表
|
||||
|
||||
|
||||
### 赞赏列表
|
||||
|
||||
|
||||
以下排名不分先后! [详细统计]()
|
||||
以下排名不分先后! [传送门→]() **赞赏过的一定要微信跟我说呀!!!!!!**
|
||||
|
||||
|
||||
<div>
|
||||
<a href="https://github.com/ChiefPing" target="_blank">
|
||||
<a href="https://github.com/ChiefPing" target="_blank" style="margin: 5px">
|
||||
<img src="https://avatars2.githubusercontent.com/u/34122068?s=460&v=4" width="50px" style="brder-radius:5px;"/>
|
||||
</a>
|
||||
<a name="gzh"></a>
|
||||
<a href="https://github.com/xiaoliuxin" target="_blank">
|
||||
<a href="https://github.com/xiaoliuxin" target="_blank" style="margin: 5px">
|
||||
<img src="https://avatars2.githubusercontent.com/u/60652527?s=460&v=4" style="border-radius:5px;" width="50px"/>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
### 赞助商
|
||||
## 赞助商
|
||||
|
||||
以下排名不分先后! 哈哈哈,还木有收到赞助,先留坑
|
||||
**以下排名不分先后! 还木有收到赞助,哈哈哈,先留坑**
|
||||
|
||||
|
||||
|
||||
---
|
||||
### 联系作者
|
||||
|
||||
<div class="open-info-div">
|
||||
<!-- <a href="#gzh" target="self_blank"><img src="https://img.shields.io/badge/WeChat-公众号-5wd.svg"></a>
|
||||
<a href="#wechat" target="_blank"><img src="https://img.shields.io/badge/WeChat-微信-yellow.svg"></a> -->
|
||||
<a href="https://space.bilibili.com/350937042" target="_blank"><img src="https://img.shields.io/badge/Bilibili-B站-green.svg"></a>
|
||||
<a href="https://142vip.cn" target="_blank"><img src="https://img.shields.io/badge/142vip-网站-orange.svg"></a>
|
||||
<a href="https://blog.142vip.cn" target="_blank"><img src="https://img.shields.io/badge/blog-博客-blue.svg"></a>
|
||||
<a href="https://github.com/mmdapl" target="_blank"><img src="https://img.shields.io/badge/Github-Github-9ac.svg"></a>
|
||||
<a href="https://gitee.com/mmdapl" target="_blank"><img src="https://img.shields.io/badge/Gitee-码云-4ed.svg"></a>
|
||||
<a href="https://blog.csdn.net/Mmdapl" target="_blank"><img src="https://img.shields.io/badge/csdn-CSDN-8ea.svg"></a>
|
||||
<a href="https://juejin.im/user/448256476724807" target="_blank"><img src="https://img.shields.io/badge/JueJin-掘金-75c.svg"></a>
|
||||
## 联系作者
|
||||
|
||||
若系列文章对你有所帮助,欢迎订阅公众号或微信”骚扰“,获取更多内容。**商务合作请备注来意**
|
||||
|
||||
<div style="text-align: center">
|
||||
<div align="center" >
|
||||
<table style="border:none;cell-padding:0; cell-spacing:0;border-collapse:collapse;" border="0">
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/media/fairy-sister-450x450.jpg"
|
||||
width="250px"
|
||||
title="欢迎关注公众号:Rong姐姐好可爱" alt="关注公众号"/>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/media/chu-fan-443-650x650.jpg"
|
||||
width="250px"
|
||||
title="欢迎添加微信:chufan443 " alt="联系作者"/>
|
||||
</table>
|
||||
</div>
|
||||
<div style="text-align: center;padding: 10px" align="center">
|
||||
<a
|
||||
href="https://github.com/mmdapl"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转Github主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/github.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://gitee.com/Mmdapl"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转码云主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/gitee.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://juejin.im/user/448256476724807"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转掘金主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/juejin.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://space.bilibili.com/350937042"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转B站主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/bilibili.svg"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
<a
|
||||
href="https://blog.csdn.net/Mmdapl"
|
||||
rel="nofollow noreferrer"
|
||||
target="_blank"
|
||||
title="点击跳转CSDN博客主页"
|
||||
>
|
||||
<img src="https://cdn.staticaly.com/gh/142vip/cdn_service@main/main-vip/svg/csdn.svg"
|
||||
title="点击跳转CSDN博客主页"
|
||||
style="margin: 5px;width: 24px;height: 24px;">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
若系列文章对你有所帮助,欢迎订阅公众号,获取更多内容。也可微信”骚扰“,商务合作请备注来意
|
||||
|
||||
<!-- <div align="left">
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/wechat_code.jpg" width="300" height="300" style="border-radius:5px;"/>
|
||||
</div> -->
|
||||
|
||||
|
||||
<a name="gzh"></a>
|
||||
|
||||
|
||||
<p>
|
||||
<img src="https://cdn.jsdelivr.net/gh/lir0115/images@main/qr_code/gongzhonghao.jpg" style="border-radius:10px;">
|
||||
</p>
|
||||
|
||||
交流/加群/互看朋友圈
|
||||
当然:**聊天 /提问 /建议 /提需求** 可以在本公众号直接**私信**,后台可以看到,有时间即会回复,偶尔的延迟和疏漏还请小伙伴们谅解,蟹蟹。
|
||||
|
||||
|
||||
|
||||
|
||||
### 外链
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
- 明确栈是一种线性表
|
||||
- 限定栈只能在某一端进行插入或者删除操作
|
||||
|
||||

|
||||

|
||||
|
||||
`栈顶`:线性表允许进行插入和删除的一端。
|
||||
|
||||
|
||||