网站大量收购独家精品文档,联系QQ:2885784924

华工软件基础第2章_数据结构与算法_第2节_线性表浅析.ppt

华工软件基础第2章_数据结构与算法_第2节_线性表浅析.ppt

  1. 1、本文档共100页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第2章 数据结构与算法;学习内容和目标;Subsection 1 Basic Concept;Definition of List A list of elements(数据元素) of type T is a finite sequence(有限序列) of elements of T together with the following operations (操作):;6. Insert(插入) an entry(数据元素) at a specified position of the list. 7. Remove(删除) an entry from a specified position in the list. 8. Retrieve(检索) the entry from a specified position in the list. 9. Replace(替换) the entry at a specified position in the list. 10. Traverse(遍历) the list, performing(执行) a given operation on each entry. 遍历:逐项访问数据元素(每个元素只访问一次);线性表 (Linear List);线性表元素的逻辑关系;抽象数据类型线性表的定义如下:; 基本操作:;初始化操作 InitList( L ) 操作结果:构造一个空线性表L;Empty( L )(判断线性表是否为空) 初始条件:线性表L已存在。 操作结果:若L为空表,则返回TRUE,否则FALSE。;Prior( L, x, pre ) (求数据元素的前驱) 初始条件:线性表L已存在。 操作结果:若x是L的元素,但不是第一个,则用pre 返回它的前驱,否则操作失败,pre无定义。;Get( L, i )(获取线性表中某个数据元素) 初始条件:线性表L已存在,且1≤i≤Length(L)。 操作结果:返回L中第 i 个元素的值。;Clear( L ) (线性表置空) 初始条件:线性表L已存在。 操作结果:将L重置为空表。;Insert( L, i, x ) (插入数据元素) 初始条件:线性表L已存在,且1≤i≤Length(L)+1 操作结果:在L的第i个元素之前插入新的元素x,L的长度增1。;线性表的存储结构;Subsection 2 Sequential List (顺序表) ——线性表的顺序存储结构;顺序表 (Sequential List);一维数组实现顺序表;顺序表(SeqList)的定义(C语言实现);顺序表(SeqList)类的定义(C++类实现); int Locate ( Type x ) const; //定位 int Insert ( int i, Type x ); //插入 int Delete ( int i ); //删除 int Next ( Type x, Type next ) ; //后继 int Prior ( Type x, Type pre ) ; //前驱 int Empty ( ) { return last ==-1; } //判空 int Full ( ) { return last == MaxSize-1; } Type Get ( int i ) { //提取 return i 0 || i last?NULL : data[i]; } } ;顺序表(SeqList)类的定义(C++类模板实现); int Locate ( Type x ) const; //定位 int Insert ( int i, Type x ); //插入 int Delete ( int i ); //删除 int Next ( Type x, Type next ) ; //后继 int Prior ( Type x, Type pre ) ; //前驱

文档评论(0)

1112111 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档