mirror of
https://github.com/142vip/408CSFamily.git
synced 2026-04-15 10:50:38 +08:00
update sqList
This commit is contained in:
BIN
数据结构/.DS_Store
vendored
BIN
数据结构/.DS_Store
vendored
Binary file not shown.
BIN
数据结构/栈和队列/.DS_Store
vendored
BIN
数据结构/栈和队列/.DS_Store
vendored
Binary file not shown.
@@ -201,7 +201,7 @@ int DeLoopQueue(SqQueue &Q, ElemType &x){
|
||||
Q.front=(Q.front+1)%MaxSize;
|
||||
Q.tag=0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
#####
|
||||
|
||||
BIN
数据结构/线性表/.DS_Store
vendored
BIN
数据结构/线性表/.DS_Store
vendored
Binary file not shown.
@@ -4,7 +4,7 @@
|
||||
* @Author: 【B站&公众号】Rong姐姐好可爱
|
||||
* @Date: 2021-03-07 21:57:52
|
||||
* @LastEditors: 【B站&公众号】Rong姐姐好可爱
|
||||
* @LastEditTime: 2021-03-07 21:58:00
|
||||
* @LastEditTime: 2021-03-19 08:16:00
|
||||
-->
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
`顺序表`:顺序存储的线性表,**是用一组地址连续的存储单元,依次存储线性表中的数据元素,使得在逻辑上相邻的两个元素在物理位置上也相邻。**
|
||||
|
||||
|
||||

|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ L.data=new ElemType[InitSize];
|
||||
在顺序表L的第i(1≤i≤L.length+1)个位置插入新的元素e
|
||||
|
||||
- 第一步:如果i非法,则直接返回false,插入失败,结束插入过程
|
||||
- 第二步:i正常,将表的第i个元素以及后面的所有元素都像有移动一个位置,在腾出来的空位置插入元素e
|
||||
- 第二步:i正常,将表的第i个元素以及后面的所有元素都向右移动一个位置,在腾出来的空位置插入元素e
|
||||
- 第三步:顺序表插入成功,返回true
|
||||
|
||||
注意:先判空和临界值,提高算法健壮性
|
||||
@@ -148,6 +148,8 @@ bool ListInsert(SqList &L, int i, ElemType e){
|
||||
|
||||
**时间复杂度**
|
||||
|
||||

|
||||
|
||||
- 最好情况:在表尾插入,元素向后移动循环没有执行,时间复杂度O(1);
|
||||
- 最坏情况:在表头插入,元素后移循环执行n次,时间复杂度为O(n);
|
||||
- 平均情况:随机插入,平均次数为:n/2,对应的平均复杂度为O(n);
|
||||
@@ -212,7 +214,8 @@ bool ListDelete(SqList &L, int i, ElemType &e){
|
||||
|
||||
|
||||
**时间复杂度:**
|
||||
|
||||
|
||||

|
||||
|
||||
- 最好情况:删除表尾元素,不需要移动任何元素,时间复杂度为O(1);
|
||||
- 最坏情况:删除表头元素,需要移动除第一个元素外的所有元素,时间复杂度为O(n);
|
||||
|
||||
Reference in New Issue
Block a user