[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
2.1.1 线性表的定义
线性表(Linear List):
由n(n>=0)个数据元素(结点)a1,a2,...,an组成的有限序列,其中数据元素的个数n为表的长度,n = 0 时称为空表。
同一线性表中的元素必定具有相同特性,数据元素的关系时线性的。
2.1.2 线性表的特点
1、在非空的线性表中,有且仅有一个开始结点a1,它没有直接前趋,仅有一个直接后继;
2、有且仅有一个终端结点,它没有直接后继,仅有一个直接前趋;
3、其余的内部结点(2 <= i < n-1)都有且仅有一个直接前趋和一个直接后继。
线性表时一种典型的线性结构。
2.1.3线性表的抽象数据类型
ADT List { Data 数据对象:D = {ai | ai属于Elemset,(i = 1, 2, ..., n, n >= 0)} 数据关系:R
= {<ai-1, ai> | ai-1, ai属于D,(i = 2, 3, ..., n)} Operation InitList(*L);
操作结果:构造一个空的线性表L。 ListEmpty(L); 初始条件:线性表L已存在; 操作结果:若线性表为空返回true,否则返回false;
GetElem(L, i, *e); 初始条件:线性表L已存在,1 <= i <= ListLength(L);
操作结果:用e返回线性表L中第i个数据元素的值; LocateElem(L, e, compare());
初始条件:线性表L已存在,compare()是数据元素的判定函数;
操作结果:返回L中第一个与e满足compare()的数据元素的位序,若这样的元素不存在,则返回0; PriorElem(L, cur_e, *pre_e);
初始条件:线性表L已存在; 操作结果:若cur_e是L的数据元素,且不是第一个,则用pre_e返回它的前趋,否则操作失败; NextElem(L,
cur_e, *next_e); 初始条件:线性表L已存在;
操作结果:若cur_e是L的数据元素,且不是最后一个,则用next_e返回它的后继,否则操作失败; ListInsert(*L, i, e);
初始条件:线性表L已存在,1 <= i <= ListLength(L)+1; 操作结果:在第i个位置之前插入数据元素e,L的长度+1;
ListDelete(*L, i, *e); 初始条件:线性表L已存在,1 <= i <= ListLength(L);
操作结果:删除线性表L中的第i个元素,并用e返回它的值,L的长度-1; ListTraverse(*L, visited()); 初始条件:线性表L已存在;
操作结果:依次对线性表的数据元素调用visited(); ListLength(L); 初始条件:线性表L已存在; 操作结果:返回线性表L中数据元素的个数;
ClearList(*L); 初始条件:线性表L已存在; 操作结果:将线性表L重置为空表; DestroyList(*L); 初始条件:线性表L已存在;
操作结果:销毁线性表L; }