- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Chapter 17 Linked Lists.ppt
Chapter 17 Linked Lists 17.1 Introduction to the Linked List ADT A linked list is a series of connected nodes, where each node is a data structure. A linked list can grow or shrink in size as the program runs Advantages of Linked Lists over Arrays and vectors A linked list can easily grow or shrink in size. Insertion and deletion of nodes is quicker with linked lists than with vectors. The composition of a Linked List Each node in a linked list contains one or more members that represent data. In addition to the data, each node contains a pointer, which can point to another node. The composition of a Linked List A linked list is called linked because each node in the series has a pointer that points to the next node in the list. Declarations First you must declare a data structure that will be used for the nodes. For example, the following struct could be used to create a list where each node holds a float: Declarations The next step is to declare a pointer to serve as the list head, as shown below. 17.2 Linked List Operations We will use the following class declaration (on the next slide), which is stored in FloatList.h. Appending a Node to the List To append a node to a linked list means to add the node to the end of the list. The pseudocode is shown below. The C++ code follows. Program 17-1 Stepping Through the Program The head pointer is declared as a global variable. head is automatically initialized to 0 (NULL), which indicates that the list is empty. ?The first call to appendNode passes 2.5 as the argument. In the following statements, a new node is allocated in memory, 2.5 is copied into its value member, and NULL is assigned to the nodes next pointer. Traversing the List The displayList member function traverses the list, displaying the value member of each node. The following pseudocode represents the algorithm. The C++ code for the member function follows on the next slide. Program 17-2 Program 17-2 Output Inserting a Node Using the listNode
您可能关注的文档
- A Recovery-Friendly, Self-Managing Session State Store.ppt
- A Taste of Technology.ppt
- A women's world, a better world.ppt
- A Workflow Approach to Designed Reservoir Study.ppt
- AARP Tax-Aide Regional MeetingsOctober 2010.ppt
- ABB Tube Mills.ppt
- Accelerator Generated Backgroundsfor e+e- B-Factories.ppt
- Access to UK computing.ppt
- Accounts Receivable and Bad Debts Expense.ppt
- Achromatic and Colored Light.ppt
- Chapter 17 Relative Pronouns.ppt
- Chapter 17 The first law of thermodynamics.ppt
- Chapter 17 The Thigh, Hip, Groin, and Pelvis.ppt
- Chapter 17 Thermal Behavior of Matter.ppt
- Chapter 17Career ManagementNelson & Quick.ppt
- Chapter 17Contracts — Breach of Contract and Remedies.ppt
- Chapter 17Informal Reports.ppt
- Chapter 17Kinetic Theory of Gases.ppt
- Chapter 17Kingdom Monera and Viruses.ppt
- Chapter 17Multiunit Controller Design.ppt
最近下载
- 河南省建设工程安全生产标准化图集.docx VIP
- 别克英朗GT说明书.docx VIP
- 洪水计算(推理公式法).xls VIP
- 初中音乐 西南师大课标版 七年级上册 走进歌乐山 《走进歌乐山》 课件.ppt VIP
- (高清版)DBJ∕T 13-278-2025 《福建省电动汽车充电基础设施建设技术标准》.pdf VIP
- 带式输送机头尾部基础荷载计算书.xls VIP
- 建筑《工程质量》首件验收制度.docx VIP
- (高清版)DB21∕T 4071-2024 沥青路面再生集料应用技术规程.pdf VIP
- 中国冰沙机行业市场现状分析及竞争格局与投资发展研究报告2024-2029版.docx
- Word操作培训ppt课件.pptx VIP
文档评论(0)