顺序表与链表比较
链式储存结构优缺点
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/75acfef31b27474a92cf45fda8ba7b5f.png)
存储密度
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/e3c0964ce272f667d381acd835aaf4d2.png)
比较
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/5563cc10979667401f9718aeb31c1418.png)
线性表的应用
线性表,有序表的合并
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/10539cbbd14473915d06e22db7896221.png)
线性表
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/9adf5a53eaa021c48049f90a74e22e38.png)
void union_L(List& La, List& Lb) {
int La_len = GetLength(La);
int Lb_len = GetLength(Lb);
for (int i = 1; i <= Lb_len; i++) {
ElemType e;
GetElem(Lb, i, &e);
if (!LocateElem(&La, e)) Insert(&La, ++La_len, e);
}
}
有序表
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/a22512e94eecea07659f115b32827949.png)
顺序表
void Merge_L(SqList La, SqList Lb, SqList& Lc) {
ElemType *pa = La.elem;
ElemType *pb = Lb.elem;
Lc.length = La.length + Lb.length;
Lc.elem = new ElemType[Lc.length];
ElemType* pc = Lc.elem;
ElemType* pa_last = La.elem + La.length - 1;
ElemType* pb_last = Lb.elem + Lb.length - 1;
while (pa <= pa_last && pb <= pb_last) {
if (*pa <= *pb) *pc++ = *pa++;
else *pc++ = *pb++;
}
while(pa <= pa_last) *pc++ = *pa++;
while (pb <= pb_last) *pc++ = *pb++;
}
链表
案例分析与实现