diff --git a/README.md b/README.md index 3db77c2..a79ad4f 100644 --- a/README.md +++ b/README.md @@ -151,144 +151,6 @@ - 外部排序方法整理 -### 算法刷题 - -> 刷题部分来源于自己在牛客网的刷题练习,编程语言大部分采用的是javascript - - -#### [剑指真题](https://www.nowcoder.com/ta/coding-interviews) - -### 数组和矩阵 - - - [【简单】数组中重复的数字](./算法/剑指/数组和矩阵/duplicate.js) - - [【中等】二维数组中的查找](./算法/剑指/数组和矩阵/Find.js) - - [【较难】替换空格](./算法/剑指/数组和矩阵/replaceSpace.js) - - [【较难】顺时针打印矩阵](./算法/剑指/数组和矩阵/printMatrix.js) - - [【简单】第一个只出现一次的字符位置](./算法/剑指/数组和矩阵/FirstNotRepeatingChar.js) - - -### 栈队列堆 - -- [【简单】两个栈实现队列](./算法/剑指/栈队列堆/JSStackToQueue.js) -- [【中等】最小的k个数](./算法/剑指/栈队列堆/GetLeastNumbers_Solution.js) -- [【中等】数据流中的中位数](./算法/剑指/栈队列堆/InsertAndGetMedian.js) -- [【中等】字符流中的第一个不重复的字符](./算法/剑指/栈队列堆/FirstAppearingOnce.js) -- [【较难】滑动窗口的最大值](./算法/剑指/栈队列堆/maxInWindows.js) -- [【较难】包含min函数的栈](./算法/剑指/栈队列堆/GetMinInJSStack.js) -- ~~栈的压入、弹出序列~~ - - - -### 双指针 - -- [【中等】和为S的两个数字](./算法/剑指/双指针/FindNumbersWithSum.js) -- [【中等】和为S的连续正数序列](./算法/剑指/双指针/FindContinuousSequence.js) -- [【中等】左旋转字符串](./算法/剑指/双指针/LeftRotateString.js) -- [【较难】翻转单词顺序列](./算法/剑指/双指针/ReverseSentence.js) - - - -### 链表 - -- [【简单】合并两个排序的链表](./算法/剑指/链表/Merge.js) -- [【简单】两个链表的第一个公共结点](./算法/剑指/链表/FindFirstCommonNode.js) -- [【中等】链表中倒数第K个结点](./算法/剑指/链表/FindKthToTail.js) -- [【中等】反转链表](./算法/剑指/链表/ReverseList.js) -- [【较难】从尾到头打印链表](./算法/剑指/链表/printListFromTailToHead.js) -- ~~在O(1)时间内删除链表节点~~ -- [【较难】删除链表中重复的结点](./算法/剑指/链表/deleteDuplication.js) -- ~~链表中环的入口结点[暂时没思路]~~ -- ~~【较难】复杂链表的复制[暂时没有思路]~~ - - - -### 树 - -- [【中等】重建二叉树](./算法/剑指/树/reConstructBinaryTree.js) -- [【中等】二叉树的下一个结点](./算法/剑指/树/GetNext.js) -- [【较难】树的子结构](./算法/剑指/树/HasSubtree.js) -- 二叉树的镜像 -- 对称的二叉树 -- 从上往下打印二叉树 -- 把二叉树打印成多行 -- 二叉搜索树的后续遍历序列 -- 二叉树中和为某一值的路劲 -- 二叉搜索树和双向链表 -- 序列化二叉树 -- 二叉查找树的第K个结点 -- 二叉树的深度 -- 平衡二叉树 -- 树中两个节点的最低公共祖先 - - -### 综合类型 - -#### 贪心思想 - -- 剪绳子 -- [【LeetCode题目】股票的最大利润](./算法/剑指/贪心思想/maxProfit.js) - - -#### 二分查找 - -- [【简单】旋转数组的最小数字](./算法/剑指/二分查找/minNumberInRotateArray.js) -- [【中等】数字在排序数组中出现的次数](./算法/剑指/二分查找/GetNumberOfK.js) - - -#### 分治 - -- [【中等】数值的整数次方](./分治/Power.js) - - -#### 搜索 - -- 矩阵中的路径 有难度 -- 机器人的运动范围 -- 字符串的排列 - - -#### 排列 - -- [【中等】调整数组顺序使奇数位于偶数前面](./算法/剑指/排列/reOrderArray.js) -- [【较难】把数组排成最小的数](./算法/剑指/双指针/ReverseSentence.js) -- 数组中的逆序对 困难 - -#### 动态规划 - -- [【入门】斐波拉契数列](./算法/剑指/动态规划/Fibonacci.js) -- [【简单】变态跳台阶 找规律 可跳任意阶](./算法/剑指/动态规划/jumpFloorII.js) -- [【简单】连续子数组的最大和 时间复杂度O(n)](./算法/剑指/动态规划/FindGreatestSumOfSubArray.js) -- [【简单】构建乘积数组](./算法/剑指/动态规划/multiply.js) -- [【中等】矩形覆盖](./算法/剑指/动态规划/rectCover.js) -- [【中等】跳台阶 非递归,要么跳一阶,要么跳两阶](./算法/剑指/动态规划/jumpFloor.js) -- [【较难】丑数](./算法/剑指/动态规划/GetUglyNumber_Solution.js) - - - -#### 数学问题 - -- [【简单】数组中出现次数超过一半的数字](./算法/剑指/数学/MoreThanHalfNum_Solution.js) -- [【中等】圆圈中最后剩下的数 约瑟夫问题](./算法/剑指/数学/LastRemaining_Solution.js) -- [【中等】从1到n整数中1出现的次数](./算法/剑指/数学/NumberOf1Between1AndN_Solution.js) -#### 位运算 - -- [【中等】二进制中1的个数](./算法/剑指/位运算/NumberOf1.js) -- [【中等】数组中只出现一次的数字](./算法/剑指/位运算/FindNumsAppearOnce.js) - -#### 其他分类 - -- [【简单】不用加减乘除做加法](./算法/剑指/其他相关/Add.js) -- [【中等】扑克牌顺子](./算法/剑指/其他相关/IsContinuous.js) -- [【较难】把字符串转换成整数](./算法/剑指/其他相关/StrToInt.js) - - - -#### [前端常考](https://www.nowcoder.com/activity/oj?tab=3) - - -#### [后端常考](https://www.nowcoder.com/activity/oj?tab=0) - - ### 计算机网络 diff --git a/code/ds/BinaryInsertSort.cpp b/code/ds/BinaryInsertSort.cpp index a1ef8ab..072b88e 100644 --- a/code/ds/BinaryInsertSort.cpp +++ b/code/ds/BinaryInsertSort.cpp @@ -1,43 +1,35 @@ -/* - * @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; + int i,j,lowIndex,highIndex,midIndex; for(i=2;j<=n;i++){ // 将待排序的元素暂存在Arr[0]上 Arr[0]=Arr[i]; lowIndex=1; // 左侧子表 折半查找起始位置 - heightIndex=i-1; // 左侧子表 折半查找结束位置 - - while(lowIndex<=heightIndex){ + highIndex=i-1; // 左侧子表 折半查找结束位置 + while(lowIndex<=highIndex){ // 左侧有序子表的中间位置角标 midIndex=(lowIndex+heightIndex)/2; if(Arr[midIndex].key>Arr[0].key){ // 小于中间元素,插入位置在子表左侧 - heightIndex=mid-1 + highIndex=mid-1 }else{ // 大于或者等于中间元素,插入位置在子表右侧 lowIndex=midIndex+1; } } - // 跳出循环需要(lowIndex>heightIndex),说明待插入位置的角标在heightIndex之后,为 heightIndex+1,此时需要将(heightIndex,i)之间的所有元素后移 + // 跳出循环需要(lowIndex>heightIndex), + // 说明待插入位置的角标在heightIndex之后,为 heightIndex+1,此时需要将(heightIndex,i)之间的所有元素后移 - for(j=i-1;j>heightIndex;--j){ + for(j=i-1;j>highIndex;--j){ Arr[j+1]=Arr[j] } - // 后移完成后,将元素Arr[0]赋值到位置(hightIndex+1)上 - Arr[heightIndex+1]=Arr[0] + // 后移完成后,将元素Arr[0]赋值到位置(highIndex+1)上 + Arr[highIndex+1]=Arr[0] } } diff --git a/code/ds/BinaryInsertSort.js b/code/ds/BinaryInsertSort.js index 1c0e92b..1ef9d8d 100644 --- a/code/ds/BinaryInsertSort.js +++ b/code/ds/BinaryInsertSort.js @@ -1,21 +1,11 @@ -/* - * @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 arr - * @param len + * 折半插入排序【JavaScript版本】 */ function binaryInsertSort(arr, len) { // 数组长度校验【非必须】 - len = arr.length === len ? len : arr.length - + len = arr.length === len + ? len + : arr.length for (let i = 1; i < len; i++) { const temp = arr[i] @@ -23,7 +13,7 @@ function binaryInsertSort(arr, len) { while (lowIndex <= highIndex) { // 注意:取整,javascript这里取整,会出现空指针 - const mid = parseInt((lowIndex + highIndex) / 2) + const mid = Math.ceil((lowIndex + highIndex) / 2) if (arr[mid] <= temp) { // 右侧 @@ -34,7 +24,6 @@ function binaryInsertSort(arr, len) { } } // 元素后移 - for (let j = i - 1; j > highIndex; --j) { arr[j + 1] = arr[j] } diff --git a/code/ds/BubbleSort.cpp b/code/ds/BubbleSort.cpp index 9eafd90..6b30db4 100644 --- a/code/ds/BubbleSort.cpp +++ b/code/ds/BubbleSort.cpp @@ -1,24 +1,11 @@ -/* - * @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;ii;j--){ if(A[j-1].key>A[j].key){ - // 将两个元素A[j-1]、A[j]进行交换,有多种方法 swap(A[j-1],A[j]) // 确认已发生交换 @@ -35,7 +22,6 @@ void BubbleSwapSort(ElemType A[], int n){ /** * 加减法实现两个元素值互换 - * */ void swap(int a, int b){ // 此时a为两值的和 @@ -46,10 +32,8 @@ void swap(int a, int b){ a=a-b; } -/** - * 临时变量实现两个元素值的互换 - * - */ + +// 临时变量实现两个元素值的互换 void swap(int a,int b){ int temp; temp=a; diff --git a/code/ds/BubbleSort.js b/code/ds/BubbleSort.js index fc318d7..605a80f 100644 --- a/code/ds/BubbleSort.js +++ b/code/ds/BubbleSort.js @@ -1,13 +1,6 @@ -/* - * @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 +/** + * 冒泡排序【JavaScript版本】 */ - - function BubbleSort(arr, len) { // 校正数组的长度 len = arr.length === len ? len : arr.length @@ -38,20 +31,6 @@ function BubbleSort(arr, len) { return arr } - -/** - * 加减法交换元素的值 - * 注意:JavaScript中使用需要考虑到作用域的问题 - * @param a - * @param 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) diff --git a/code/ds/LinkList.cpp b/code/ds/LinkList.cpp index 1d050fc..dc731fd 100644 --- a/code/ds/LinkList.cpp +++ b/code/ds/LinkList.cpp @@ -1,110 +1,78 @@ -/* - * @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=(LNode*)malloc(sizeof(LNode)); // 结点数据域赋值 - s->data=x; + 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; @@ -112,7 +80,7 @@ LNode *GetElem(LinkList L,int i){ // p存在且计数没有走到初始i的位置 while(p&&jnext; @@ -125,19 +93,12 @@ LNode *GetElem(LinkList L,int i){ // 跳出循环,返回第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的结点 @@ -145,11 +106,11 @@ LNode *LocateElem(LinkList L,ElemType e){ // 无法匹配,指针后移 p=p->next; } - + // 注意:p为NULL的时候,说明单链表已经遍历的尾结点了,跳出循环,没有找到目标结点; // 查找到第1个匹配的结点,跳出循环,返回结点指针 return p; - // + // } diff --git a/code/ds/LinkStack.cpp b/code/ds/LinkStack.cpp index d13e89e..ed95c26 100644 --- a/code/ds/LinkStack.cpp +++ b/code/ds/LinkStack.cpp @@ -1,12 +1,3 @@ -/* - * @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; // 栈元素结点数据域 @@ -15,28 +6,21 @@ typedef struct LinkNode{ // 更为详细的定义 -typedef struct StackNode +typedef struct StackNode { int data;//结点数据域 struct StackNode* next;//结点指针域 }StackNode,* Linktop; - + //链栈的数据结构 -typedef struct LinkStack +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){ // 判断链栈是否存在 @@ -47,20 +31,18 @@ bool linkStackPushNode(LinkStack* linkStack,int e){ // 开辟栈结点元素内存控件 StackNode* node = (StackNode*)malloc(sizeof(StackNode)); // 新结点指针域指向链表,即栈顶指针位置,元素加入链表 - node->next = linkStack->top; + node->next = linkStack->top; // 新结点数据域赋值 node->data = e; // 元素进栈,移动栈顶指针,指向新入栈的元素 - linkStack->top = node; - // 链栈元素总数+1 + linkStack->top = node; + // 链栈元素总数+1 linkStack->count++; //链栈入栈成功,返回true return true; } - - /* * @Description: 基于单链表链栈的出栈操作 * @Version: Beta1.0 @@ -81,10 +63,10 @@ bool linkStackPopNode(LinkStack* linkStack,int *e){ // 结点元素数据域赋值给变量e *e = linkStack->data; // 移动栈顶指向,栈顶指针指向待出栈结点的后继结点 - linkStack->top = node->next; + linkStack->top = node->next; // 变量e已被赋值,释放链栈出栈元素的内存控件 - free(node); - // 链栈元素个数-1 + free(node); + // 链栈元素个数-1 linkStack->count--; // 出栈成功,返回true. return true; diff --git a/code/ds/LoopQueue.cpp b/code/ds/LoopQueue.cpp index 02dc1d6..19af1b0 100644 --- a/code/ds/LoopQueue.cpp +++ b/code/ds/LoopQueue.cpp @@ -1,14 +1,3 @@ -/* - * @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 diff --git a/code/ds/QuickSort.cpp b/code/ds/QuickSort.cpp index 7eb0232..749c747 100644 --- a/code/ds/QuickSort.cpp +++ b/code/ds/QuickSort.cpp @@ -1,15 +1,5 @@ -/* - * @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=pivot) --high A[low]=A[high] // 比pivot小的都移到左表 注意--high 从后往前遍历 - while(low=1;k=k/2){ diff --git a/code/ds/ShellSort.js b/code/ds/ShellSort.js index 6792c79..236a433 100644 --- a/code/ds/ShellSort.js +++ b/code/ds/ShellSort.js @@ -1,19 +1,10 @@ -/* - * @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 返回已排序的数组,从小到大 + * @returns */ function shellSort(arr, len) { // 校对数组长度 @@ -60,37 +51,6 @@ function specialStraightInsertSort(arr, len, increment, groupIndex) { } -/** - * 插入排序 - * @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) @@ -99,8 +59,8 @@ console.log('插入排序后:', sortResult) /** * 简化的希尔排序 + * - 返回已排序号的数组,从小到大 * @param {Array} arr - * @returns 返回已排序号的数组,从小到大 */ function shellSortBetter(arr) { const len = arr.length @@ -108,10 +68,10 @@ function shellSortBetter(arr) { while (increment !== 0) { for (let i = increment; i < len; i++) { const temp = arr[i] - for (var j = i - increment; j >= 0 && temp < arr[j]; j -= increment) { + for (let j = i - increment; j >= 0 && temp < arr[j]; j -= increment) { arr[j + increment] = arr[j] } - arr[j + increment] = temp + arr[i + increment] = temp } increment = Math.floor(increment / 2) } diff --git a/code/ds/SqList.cpp b/code/ds/SqList.cpp index 7b4a15f..74dca12 100644 --- a/code/ds/SqList.cpp +++ b/code/ds/SqList.cpp @@ -1,13 +1,5 @@ -/* - * @Description: 顺序表的基础操作 - * @Version: Beta1.0 - * @Author: 【B站&公众号】Rong姐姐好可爱 - * @Date: 2021-02-23 07:48:26 - * @LastEditors: 【B站&公众号】Rong姐姐好可爱 - * @LastEditTime: 2021-02-23 07:48:26 - */ +// 顺序表的基础操作 - // 基础结构体 @@ -60,7 +52,7 @@ bool ListDelete(SqList &L, int i, ElemType &e){ if(L.length >= MaxSize){ return false; } - + // 引用变量e赋值 e=L.data[i-1] @@ -70,7 +62,7 @@ bool ListDelete(SqList &L, int i, ElemType &e){ L.data[j-1]=L.data[j]; } - // 此时,表L中的表尾元素和倒数第二个元素值一样,将表的长度-1 + // 此时,表L中的表尾元素和倒数第二个元素值一样,将表的长度-1 // 表长度减1 L.length--; diff --git a/code/ds/StraightInsertSort.cpp b/code/ds/StraightInsertSort.cpp index 1827725..098ed8d 100644 --- a/code/ds/StraightInsertSort.cpp +++ b/code/ds/StraightInsertSort.cpp @@ -1,11 +1,4 @@ -/* - * @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; diff --git a/code/ds/StraightInsertSort.js b/code/ds/StraightInsertSort.js index 76e0069..d99b507 100644 --- a/code/ds/StraightInsertSort.js +++ b/code/ds/StraightInsertSort.js @@ -1,17 +1,5 @@ -/* - * @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()计算得到 + * 直接插入排序【JavaScript版本】 */ function straightInsertSort(arr, len) { // 重新确定数组长度 @@ -29,7 +17,6 @@ function straightInsertSort(arr, len) { arr[j + 1] = arr[j] } // 跳出循环逻辑,出现arr[j] > arr[j-1] - // 哨兵即待排序的 arr[j + 1] = temp } diff --git a/docs/.vuepress/config/navbar.ts b/docs/.vuepress/config/navbar.ts index ad912d8..be0036f 100644 --- a/docs/.vuepress/config/navbar.ts +++ b/docs/.vuepress/config/navbar.ts @@ -1,52 +1,55 @@ +/** + * 导航栏配置 + */ 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: '/' + }, + // { + // 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: "大事记", - link: "/big-event-history" - }, - { - text: '其他', - link: "/manuscripts/note-map" - }, + { + text: "计算机网络", + link: "/manuscripts/cn" + }, + { + text: "网站动态", + link: "/big-event-history" + }, + { + text: '思维导图', + link: "/manuscripts/note-map" + }, ]; diff --git a/docs/.vuepress/config/plugins.config.ts b/docs/.vuepress/config/plugins.config.ts index 4e108fe..954bb4c 100644 --- a/docs/.vuepress/config/plugins.config.ts +++ b/docs/.vuepress/config/plugins.config.ts @@ -1,14 +1,17 @@ import {searchProPlugin} from "vuepress-plugin-search-pro"; +/** + * 插件配置 + */ export default { - plugins:[ + plugins: [ searchProPlugin({ // 索引全部内容 indexContent: true, // 为分类和标签添加索引 customFields: [ { - getter: (page:any) => page.frontmatter.category, + getter: (page: any) => page.frontmatter.category, formatter: "分类:$content", }, { diff --git a/docs/.vuepress/config/sidebar.ts b/docs/.vuepress/config/sidebar.ts index 1e5a46c..3c6f06c 100644 --- a/docs/.vuepress/config/sidebar.ts +++ b/docs/.vuepress/config/sidebar.ts @@ -1,14 +1,16 @@ -import {algorithmSidebar} from "../../manuscripts/algorithm/algorithm.sidebar"; import {dsSidebar} from "../../manuscripts/ds/ds.sidebar"; import {cppSidebar} from "../../manuscripts/ccp/cpp.sidebar"; import {cnSidebar} from "../../manuscripts/cn/cn.sidebar"; import {noteMapSidebar} from "../../manuscripts/note-map/note-map.sidebar"; import {osSidebar} from "../../manuscripts/os/os.sidebar"; +/** + * 侧边导航栏设置 + */ export const sidebar = { - "/manuscripts/ds": dsSidebar, - "/manuscripts/os": osSidebar, - "/manuscripts/ccp": cppSidebar, - "/manuscripts/cn": cnSidebar, - "/manuscripts/note-map": noteMapSidebar, + "/manuscripts/ds": dsSidebar, + "/manuscripts/os": osSidebar, + "/manuscripts/ccp": cppSidebar, + "/manuscripts/cn": cnSidebar, + "/manuscripts/note-map": noteMapSidebar } \ No newline at end of file diff --git a/docs/manuscripts/algorithm/Readme.md b/docs/manuscripts/algorithm/Readme.md deleted file mode 100644 index 4b7d5ae..0000000 --- a/docs/manuscripts/algorithm/Readme.md +++ /dev/null @@ -1,13 +0,0 @@ - - - -## 算法 - -doing \ No newline at end of file diff --git a/docs/manuscripts/algorithm/algorithm.sidebar.ts b/docs/manuscripts/algorithm/algorithm.sidebar.ts deleted file mode 100644 index e0634d7..0000000 --- a/docs/manuscripts/algorithm/algorithm.sidebar.ts +++ /dev/null @@ -1,16 +0,0 @@ -export const algorithmSidebar = [ - { - 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' - }] - }] diff --git a/docs/manuscripts/algorithm/algorithm_note/Readme.md b/docs/manuscripts/algorithm/algorithm_note/Readme.md deleted file mode 100644 index a353562..0000000 --- a/docs/manuscripts/algorithm/algorithm_note/Readme.md +++ /dev/null @@ -1,12 +0,0 @@ - - -## 刷题笔记 - -doing \ No newline at end of file diff --git a/docs/manuscripts/algorithm/topic_practice/Readme.md b/docs/manuscripts/algorithm/topic_practice/Readme.md deleted file mode 100644 index efee78b..0000000 --- a/docs/manuscripts/algorithm/topic_practice/Readme.md +++ /dev/null @@ -1,20 +0,0 @@ - - - -## 习题练手 - -doing \ No newline at end of file diff --git a/docs/manuscripts/ds/basic-introduction/1.basic_concepts.md b/docs/manuscripts/ds/basic-introduction/1.basic_concepts.md index b5abea3..c8b405c 100644 --- a/docs/manuscripts/ds/basic-introduction/1.basic_concepts.md +++ b/docs/manuscripts/ds/basic-introduction/1.basic_concepts.md @@ -1,15 +1,4 @@ - - - - ## 基础概念 ### 数据 diff --git a/docs/manuscripts/ds/basic-introduction/2.three_elements_of_data_structure.md b/docs/manuscripts/ds/basic-introduction/2.three_elements_of_data_structure.md index b13a260..9d72b60 100644 --- a/docs/manuscripts/ds/basic-introduction/2.three_elements_of_data_structure.md +++ b/docs/manuscripts/ds/basic-introduction/2.three_elements_of_data_structure.md @@ -1,16 +1,4 @@ - - - - - ## 数据结构三要素 - 数据的逻辑结构 diff --git a/docs/manuscripts/ds/basic-introduction/3.algorithm_and_algorithm_evaluation.md b/docs/manuscripts/ds/basic-introduction/3.algorithm_and_algorithm_evaluation.md index 8070d6a..f176118 100644 --- a/docs/manuscripts/ds/basic-introduction/3.algorithm_and_algorithm_evaluation.md +++ b/docs/manuscripts/ds/basic-introduction/3.algorithm_and_algorithm_evaluation.md @@ -1,15 +1,4 @@ - - - - ## 算法和算法评价 diff --git a/docs/manuscripts/ds/basic-introduction/readme.md b/docs/manuscripts/ds/basic-introduction/readme.md index eb812f8..7db634c 100644 --- a/docs/manuscripts/ds/basic-introduction/readme.md +++ b/docs/manuscripts/ds/basic-introduction/readme.md @@ -1,12 +1,2 @@ - - - ![](./basic_introduction.png) \ No newline at end of file diff --git a/docs/manuscripts/ds/coding/algorithm.md b/docs/manuscripts/ds/coding/algorithm.md index 7605559..6ae8d0a 100644 --- a/docs/manuscripts/ds/coding/algorithm.md +++ b/docs/manuscripts/ds/coding/algorithm.md @@ -1,11 +1,3 @@ - ## 算法恶补 diff --git a/docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md b/docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md index d238c28..2121774 100644 --- a/docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md +++ b/docs/manuscripts/ds/linear-table/1.basic_concept_and_operation.md @@ -1,15 +1,4 @@ - - - - # 线性表的基础概念和基本操作 > 强调线性表是一种逻辑结构,不是存储结构 diff --git a/docs/manuscripts/ds/linear-table/2.sequential_representation.md b/docs/manuscripts/ds/linear-table/2.sequential_representation.md index 489466a..75d422b 100644 --- a/docs/manuscripts/ds/linear-table/2.sequential_representation.md +++ b/docs/manuscripts/ds/linear-table/2.sequential_representation.md @@ -1,14 +1,4 @@ - - - # 线性表的顺序表示 diff --git a/docs/manuscripts/ds/linear-table/3.chain_representation.md b/docs/manuscripts/ds/linear-table/3.chain_representation.md index bcb675e..38e6ad7 100644 --- a/docs/manuscripts/ds/linear-table/3.chain_representation.md +++ b/docs/manuscripts/ds/linear-table/3.chain_representation.md @@ -1,16 +1,3 @@ - - - - - - # 线性表的链式表示 顺序表的插入、删除操作需要移动大量元素,影响了运行效率(虽然时间复杂度为O(1)的情况也存在)。 diff --git a/docs/manuscripts/ds/linear-table/4.double_linked_list.md b/docs/manuscripts/ds/linear-table/4.double_linked_list.md index 78665f1..75b03b5 100644 --- a/docs/manuscripts/ds/linear-table/4.double_linked_list.md +++ b/docs/manuscripts/ds/linear-table/4.double_linked_list.md @@ -1,16 +1,4 @@ - - - - - # 双链表 diff --git a/docs/manuscripts/ds/linear-table/5.circular_list.md b/docs/manuscripts/ds/linear-table/5.circular_list.md index f3436d9..f51a8f5 100644 --- a/docs/manuscripts/ds/linear-table/5.circular_list.md +++ b/docs/manuscripts/ds/linear-table/5.circular_list.md @@ -1,16 +1,4 @@ - - - - - # 循环链表 - 循环单链表 diff --git a/docs/manuscripts/ds/linear-table/6.static_linked_list.md b/docs/manuscripts/ds/linear-table/6.static_linked_list.md index 605143a..37b4318 100644 --- a/docs/manuscripts/ds/linear-table/6.static_linked_list.md +++ b/docs/manuscripts/ds/linear-table/6.static_linked_list.md @@ -1,16 +1,4 @@ - - - - - # 静态链表 > 借助数组来描述线性表的链式存储结构,结点元素同样存在数据域`data`和指针域`next` diff --git a/docs/manuscripts/ds/linear-table/7.comparison_of_sequential_list_and_linked_list.md b/docs/manuscripts/ds/linear-table/7.comparison_of_sequential_list_and_linked_list.md index 344063f..873e463 100644 --- a/docs/manuscripts/ds/linear-table/7.comparison_of_sequential_list_and_linked_list.md +++ b/docs/manuscripts/ds/linear-table/7.comparison_of_sequential_list_and_linked_list.md @@ -1,15 +1,3 @@ - - - - - # 顺序表和链表的比较 diff --git a/docs/manuscripts/ds/linear-table/8.selection_of_storage_structure.md b/docs/manuscripts/ds/linear-table/8.selection_of_storage_structure.md index f1602cb..35e60dc 100644 --- a/docs/manuscripts/ds/linear-table/8.selection_of_storage_structure.md +++ b/docs/manuscripts/ds/linear-table/8.selection_of_storage_structure.md @@ -1,20 +1,5 @@ - - - - - - # 存储结构的选取 - - ### 基于存储的考虑 - 对线性表的长度和存储规模难以估计时,不宜采用顺序表存储 diff --git a/docs/manuscripts/ds/linear-table/9.piecemeal_knowledge_supplement.md b/docs/manuscripts/ds/linear-table/9.piecemeal_knowledge_supplement.md index d794471..afe9630 100644 --- a/docs/manuscripts/ds/linear-table/9.piecemeal_knowledge_supplement.md +++ b/docs/manuscripts/ds/linear-table/9.piecemeal_knowledge_supplement.md @@ -1,15 +1,4 @@ - - - - # 零碎知识补充 - 无论是链表的插入还是删除操作,必须保证不断链【重要】 diff --git a/docs/manuscripts/ds/linear-table/readme.md b/docs/manuscripts/ds/linear-table/readme.md index 3609c2d..c00d10f 100644 --- a/docs/manuscripts/ds/linear-table/readme.md +++ b/docs/manuscripts/ds/linear-table/readme.md @@ -1,12 +1,3 @@ - - # 线性表 ![](./线性表_水印.png) \ No newline at end of file diff --git a/docs/manuscripts/ds/栈和队列/1.栈的基本概念和基本操作.md b/docs/manuscripts/ds/栈和队列/1.栈的基本概念和基本操作.md index 9324e59..820c30c 100644 --- a/docs/manuscripts/ds/栈和队列/1.栈的基本概念和基本操作.md +++ b/docs/manuscripts/ds/栈和队列/1.栈的基本概念和基本操作.md @@ -1,14 +1,3 @@ - - - - # 基本概念和基本操作 `栈`: 只允许在一端进行插入或者删除操作的**线性表**,`后进先出的线性表`。 diff --git a/docs/manuscripts/ds/栈和队列/2.栈的顺序存储结构.md b/docs/manuscripts/ds/栈和队列/2.栈的顺序存储结构.md index af301b4..22b7ef4 100644 --- a/docs/manuscripts/ds/栈和队列/2.栈的顺序存储结构.md +++ b/docs/manuscripts/ds/栈和队列/2.栈的顺序存储结构.md @@ -1,14 +1,3 @@ - - - - # 栈的顺序存储结构 diff --git a/docs/manuscripts/ds/栈和队列/3.栈的链式存储结构.md b/docs/manuscripts/ds/栈和队列/3.栈的链式存储结构.md index 0e82361..b02c445 100644 --- a/docs/manuscripts/ds/栈和队列/3.栈的链式存储结构.md +++ b/docs/manuscripts/ds/栈和队列/3.栈的链式存储结构.md @@ -1,12 +1,3 @@ - - # 栈的链式存储结构 diff --git a/docs/manuscripts/ds/栈和队列/4.队列的基本概念和操作.md b/docs/manuscripts/ds/栈和队列/4.队列的基本概念和操作.md index 0a25b4d..1687609 100644 --- a/docs/manuscripts/ds/栈和队列/4.队列的基本概念和操作.md +++ b/docs/manuscripts/ds/栈和队列/4.队列的基本概念和操作.md @@ -1,12 +1,3 @@ - - # 队列的基本概念和操作 diff --git a/docs/manuscripts/ds/栈和队列/5.队列的顺序存储结构.md b/docs/manuscripts/ds/栈和队列/5.队列的顺序存储结构.md index 99cbfaf..c76edc1 100644 --- a/docs/manuscripts/ds/栈和队列/5.队列的顺序存储结构.md +++ b/docs/manuscripts/ds/栈和队列/5.队列的顺序存储结构.md @@ -1,13 +1,3 @@ - - - # 队列的顺序存储结构 diff --git a/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md b/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md index 67a1150..2c53a1c 100644 --- a/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md +++ b/docs/manuscripts/ds/栈和队列/6.队列的链式存储结构.md @@ -1,12 +1,3 @@ - - # 队列的链式存储结构 diff --git a/docs/manuscripts/ds/栈和队列/7.栈和队列的应用.md b/docs/manuscripts/ds/栈和队列/7.栈和队列的应用.md index 7851862..e2fad63 100644 --- a/docs/manuscripts/ds/栈和队列/7.栈和队列的应用.md +++ b/docs/manuscripts/ds/栈和队列/7.栈和队列的应用.md @@ -1,14 +1,3 @@ - - - - # 栈和队列的应用 diff --git a/docs/manuscripts/ds/栈和队列/8.特殊矩阵的压缩存储.md b/docs/manuscripts/ds/栈和队列/8.特殊矩阵的压缩存储.md index cca5a3c..48d9597 100644 --- a/docs/manuscripts/ds/栈和队列/8.特殊矩阵的压缩存储.md +++ b/docs/manuscripts/ds/栈和队列/8.特殊矩阵的压缩存储.md @@ -1,12 +1,3 @@ - - # 特殊矩阵的压缩存储 diff --git a/docs/manuscripts/ds/栈和队列/readme.md b/docs/manuscripts/ds/栈和队列/readme.md index 668b8de..beded74 100644 --- a/docs/manuscripts/ds/栈和队列/readme.md +++ b/docs/manuscripts/ds/栈和队列/readme.md @@ -1,13 +1,3 @@ - - - # 栈和队列 ### 主要内容 diff --git a/docs/manuscripts/note-map/cn-map.md b/docs/manuscripts/note-map/cn-map.md index 2bab52f..ff8ab9d 100644 --- a/docs/manuscripts/note-map/cn-map.md +++ b/docs/manuscripts/note-map/cn-map.md @@ -1,2 +1,8 @@ -# 计算机网络 \ No newline at end of file +# 计算机网络 + +