Lists Dr Nguyen Ho Man Rang Linear list concepts Array implementation Singly linked list Other linked lists Comparison of implementations of list 4 1 Chapter 4 Lists Data Structures and Algorithms Dr[.]
Trang 1Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Chapter 4
Lists
Data Structures and Algorithms
Dr Nguyen Ho Man Rang Faculty of Computer Science and Engineering
University of Technology, VNU-HCM
Trang 2Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Outcomes
• L.O.2.1 - Depict the following concepts: (a) array list
and linked list, including single link and double links,
and multiple links.
• L.O.2.2 - Describe storage structures by using
pseudocode for: (a) array list and linked list, including
single link and double links, and multiple links.
• L.O.2.3 - List necessary methods supplied for list and
describe them using pseudocode.
• L.O.2.4 - Implement list using C/C++.
Trang 3Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Outcomes
• L.O.2.5 - Use list for problems in real-life, and choose
an appropriate implementation type (array vs link).
• L.O.2.6 - Analyze the complexity and develop
experiment (program) to evaluate the efficiency of
methods supplied for list.
• L.O.8.4 - Develop recursive implementations for
methods supplied for the following structures: list.
• L.O.1.2 - Analyze algorithms and use Big-O notation to
characterize the computational complexity of algorithms
composed by using the following control structures:
sequence, branching, and iteration (not recursion).
Trang 4Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Contents
1 Linear list concepts
3 Singly linked list
4 Other linked lists
5 Comparison of implementations of list
Trang 5Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Linear list concepts
Trang 6Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Linear list concepts
Definition
A linear list is a finite, ordered sequence of
data items known as elements "Ordered" in
this definition means that each element has a
position in the list.
Trang 7Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Linear list concepts
Trang 8Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Linear list concepts
General list:
used on the list.
Trang 9Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Linear list concepts
Restricted list:
list.
ends of the list.
Trang 10Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Trang 11Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
operation on each element.
Trang 12Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
List ADT
Extended operations:
Trang 13Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Insertion
position p in the list
Trang 14Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Insertion
made at any position in the list (at the
beginning, in the middle, at the end).
inserted so that the ordering of the list
is maintained (searching appropriate
position is needed).
definition (FIFO or LIFO).
Trang 15Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Removal
position p in the list
Sorted List.
Trang 16Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Retrieval
position p in the list
Sorted List.
All elements remain unchanged.
Trang 17Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Removal, Retrieval
given data
Sorted List: Searching is needed in
order to locate the data being deleted/
retrieved.
Trang 18Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Success of Basic Operations
full.
the list is not empty.
Trang 19Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Array implementation
Trang 20Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamically Allocated Array
Trang 21Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 22Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 23Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 24Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 25Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 26Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 27Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 28Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 29Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Implementation in C++
Trang 30Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Dynamic Array: Using
Trang 31Dr Nguyen HoMan Rang
Linear list conceptsArray
implementationSingly linked listOther linked listsComparison ofimplementations oflist
Contiguous Implementation of List
In processing a contiguous list with n elements:
physical shifting ).