攻克C语言链表学习资料.pptVIP

  1. 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Data Structure Using C;Chapter 5 Linked Lists;假设有一个单链表中存储了100000个数字,这些数字从第一个节点开始依次按升序排序。 如果我们想以升序的方式显示这些数字,该怎么办呢? 答案是:从第一个节点开始遍历列表。;假如我们又需要以降序的方式显示这些数字,如何解决此问题呢? 单链表中每一个节点链接到序列中的下一个节点。这意味着我们只能以单向遍历列表。 要以降序的方式显示数字,我们需要反转(reverse)这个链表。;上述算法的存在什么问题? 无论你什么时候访问下一节点,??都需要调整三个变量的所有链接。 此方法的缺点:对长链表来说效率低且耗时。 如何解决此问题? 如果列表中每一个节点不仅包含序列中其下一个节点的地址,而且还包含其前一节点的地址,那么此问题就可以解决。;考虑下面的单链表。 我们可以在单链表的每个节点中引入一个额外的字段,它存储前一个节点的地址。这种类型的链表就是双链表 (doubly linked list)。 ;Doubly linked lists are also called two-way list or two-way chain)。 在双链表中,每个节点需要存储: ?数据 ?下一个节点的地址 ?前一个节点的地址 定义双链表中节点的结构体类型 struct node { int data; struct node *Llink; struct node *Rlink; } ;A doubly linked list is a linear data structure in which each node can have any number of data fields and two link fields which are used to point to the previous node and the next node. (page 184);The operations that can be performed on the doubly linked list are: a) insertion b) deletion c) search d) copy e) merge f) traverse The only difference between a singly linked list and doubly linked list is that two pointer nodes have to be modified. (page 184);;;;;;;c) search operation in a doubly linked list;;;f) traversing the doubly linked list;;我们可以使用单链表。 但是,武器需要以循环重复的次序显示。 因此,一旦显示了所有武器,指针必须从列表中第一个武器重新开始。 这需要在每次到达列表结尾时重新初始化指针。 在此情况下,如果遍历最后一个武器对应的节点后指针能够自动移到列表中的第一个武器,那将会更加简单。 使用循环链表(circular linked list)可以实现这一点。;A circular linked list is a linked list where the last node points to the header node. (page 198) In circlular linked list, there are no NULL links. Circular linked lists can be either of the two types: singly linked circular list doubly linked circular list ;;The operations that can be performed on circular linked list are: a) insertion b) deletion c) traversing d) searching e) merging f) splitting g) copying;traversing the circular linked list;insert a node in a circular linked list at the end;Sparse Matrices(稀疏矩阵) is a matrices contianing very few non-zero elements. (page 210) Representing large sparse matrices wastes huge amount

文档评论(0)

sunfuliang7808 + 关注
实名认证
文档贡献者

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

1亿VIP精品文档

相关文档