【精品数据结构】linear list

【精品数据结构】linear list

ID:40103323

大小:212.50 KB

页数:53页

时间:2019-07-21

【精品数据结构】linear list_第1页
【精品数据结构】linear list_第2页
【精品数据结构】linear list_第3页
【精品数据结构】linear list_第4页
【精品数据结构】linear list_第5页
资源描述:

《【精品数据结构】linear list》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、Chapter3LinearList3.1Preface1.dataobject---asetofinstancesorvaluesforexample:Boolean={false,true}Digit={0,1,2,3,4,5,6,7,8,9}Letter={A,B,……Z,a,b,……z}NaturalNumber={0,1,2,……}Integer={0,+1,-1,+2,-2,+3,-3,…}String={a,b,……,aa,ab,ac,……}3.1Preface2.datastructureisadataobjecttogetherwiththere

2、lationshipsamongtheinstancesandamongtheindividualelementsthatcomposeaninstanceData_Structure={D,R}D---dataobject,R---asetofrelationshipsofallthedatamembersinD.3.2LinearListL=(e1,e2,e3,…,en)listsizeisnifn=0:emptylistifn>0:e1isthefirst’th(orfront)elementenisthelastelementeiimmediatelypr

3、ecedesei+13.2LinearListExample:Students=(Jack,Jill,Abe,Henry,Mary,…,Judy)Exams=(exam1,exam2,exam3)DaysofWeek=(S,M,T,W,Th,F,Sa)Months=(Jan,Feb,Mar,Apr,…,Nov,Dec)3.2LinearListOperations:Createalinearlistdeterminewhetherthelistisemptydeterminethelengthofthelistfindthekthoftheelementsearc

4、hforagivenelementdeletethekthelementinsertanewelementjustafterthekth3.2LinearListADTspecificationofalinearlistAbstractDateTypeLinearList{instancesorderedfinitecollectionsofzeroormoreelementsoperationsCreate();Destroy();IsEmpty();Length();Find(k,x);Search(x);Delete(k,x);Insert(k,x);Out

5、put(out);}3.3Formula-basedRepresentation1.Useanarraytorepresenttheinstanceofanobject(e1,e2,………en)length=neachpositionofthearrayiscalledacelloranodemappingformula:location(i)=i-1e1e2e3enElement012n-1maxsize-13.3Formula-basedRepresentation2.Classdefinition:program3.1templateclas

6、sLinearList{public:LinearList(intMaxListSize=10);~LinearList(){delete[]element;};boolIsEmpty()const{returnlength==0;}intLength()const(returnlength);boolFind(intk,T&x)const;intSearch(constT&x)const;LinearList&Delete(intk,T&x);LinearList&Insert(intk,constT&x);voidOutput(ostream&ou

7、t)const;private:intlength;intMaxSize;T*element;}3.3Formula-basedRepresentation3.Operations:1)Constructor:templateLinearList::LinearList(intMaxListSize){MaxSize=MaxListSize;element=newT[MaxSize];length=0;}3.3Formula-basedRepresentation2)boolFind(intk,T&x)O(1)thek’thelementin

8、theli

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。