list general linear lists - top steptopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2...
TRANSCRIPT
![Page 1: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/1.jpg)
Data Structures: A Pseudocode Approach with C , Second Edition 1
Chapter 5
Objectives
Upon completion you will be able to:
• Explain the design, use, and operation of a linear list
• Implement a linear list using a linked list structure
• Understand the operation of the linear list ADT
• Write application programs using the linear list ADT
• Design and implement different link-list structures
List
General Linear Lists
![Page 2: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/2.jpg)
2
General linear lists
A general linear list is a list in which operations can be done anywhere in the list.
For simplicity, we refer to general linear lists as lists.
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 3: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/3.jpg)
3
5-1 Basic Operations
We begin with a discussion of the basic list operations. Each
operation is developed using before and after figures to show
the changes.
• Insertion
• Deletion
• Retrieval
• Traversal
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 4: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/4.jpg)
4
insertion
Insertion is used to add a new element to the list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 5: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/5.jpg)
5
deletion
Deletion is used to remove an element from the list.
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 6: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/6.jpg)
6
retrieval
Retrieval is used to get the information related to an element
without changing the structure of the list.
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 7: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/7.jpg)
7
traversal
List traversal processes each element in a list in sequence.
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 8: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/8.jpg)
8
Implementation
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 9: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/9.jpg)
9
Data structure
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 10: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/10.jpg)
10
Algorithms
Create list
Insert node
Delete node
List search
Retrieve node
Empty list
Full list
List count
Traverse list
Destroy list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 11: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/11.jpg)
11
Create list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 12: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/12.jpg)
12
Create list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 13: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/13.jpg)
13
Insert node
Only its logical predecessor is needed.
There are three steps to the insertion:
1. Allocate memory for the new node and move data to the node.
2. Point the new node to its successor.
3. Point the new node’s predecessor to the new node.
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 14: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/14.jpg)
14
Insert node
Insert into empty list
Insert at beginning
Insert in middle
Insert at end
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 15: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/15.jpg)
15
Insert into empty list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 16: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/16.jpg)
16
Insert at beginning
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 17: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/17.jpg)
17
Insert in middle
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 18: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/18.jpg)
Data Structures: A Pseudocode Approach with C 18
Insert at end
![Page 19: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/19.jpg)
Data Structures: A Pseudocode Approach with C 19
![Page 20: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/20.jpg)
20
Delete node
Delete first node
General delete case
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 21: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/21.jpg)
21
Delete first node
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 22: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/22.jpg)
Data Structures: A Pseudocode Approach with C 22
Delete general case
![Page 23: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/23.jpg)
Data Structures: A Pseudocode Approach with C 23
![Page 24: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/24.jpg)
24
List search
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 25: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/25.jpg)
25Data Structures: A Pseudocode Approach with C , Second Edition
![Page 26: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/26.jpg)
26Data Structures: A Pseudocode Approach with C , Second Edition
![Page 27: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/27.jpg)
27Data Structures: A Pseudocode Approach with C , Second Edition
![Page 28: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/28.jpg)
28
Retrieve node
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 29: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/29.jpg)
29
Empty list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 30: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/30.jpg)
30
Full list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 31: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/31.jpg)
31
List count
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 32: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/32.jpg)
32
Traversal list
Data Structures: A Pseudocode Approach with C , Second Edition
![Page 33: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/33.jpg)
33Data Structures: A Pseudocode Approach with C , Second Edition
![Page 34: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/34.jpg)
34Data Structures: A Pseudocode Approach with C , Second Edition
![Page 35: List General Linear Lists - TOP STEPtopstep.weebly.com/uploads/2/4/9/4/24947581/chapter05.pdf · 2 General linear lists A general linear list is a list in which operations can be](https://reader036.vdocuments.net/reader036/viewer/2022081407/6051418169ed7973b161150f/html5/thumbnails/35.jpg)
35
Destroy list
Data Structures: A Pseudocode Approach with C , Second Edition