DSA - Lecture 03
-
Upload
haitham-a-el-ghareeb -
Category
Education
-
view
3.935 -
download
0
description
Transcript of DSA - Lecture 03
![Page 1: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/1.jpg)
Collections and Generics
Dr.Haitham A. El-Ghareeb
Information Systems DepartmentFaculty of Computers and Information Sciences
Mansoura University
September 30, 2012
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 1 / 13
![Page 2: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/2.jpg)
Good News
Received: 23 September 2012
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 2 / 13
![Page 3: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/3.jpg)
Good News
http://www.helghareeb.me/courses/dsa-2012
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 3 / 13
![Page 4: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/4.jpg)
Collections
A collection is a structured data type that stores data and providesoperations for adding data to the collection.
Operations include:I removing data from the collectionI updating data in the collectionI and operations for setting and returning the values of different
attributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
![Page 5: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/5.jpg)
Collections
A collection is a structured data type that stores data and providesoperations for adding data to the collection.
Operations include:I removing data from the collectionI updating data in the collectionI and operations for setting and returning the values of different
attributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
![Page 6: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/6.jpg)
Collections
A collection is a structured data type that stores data and providesoperations for adding data to the collection.
Operations include:
I removing data from the collectionI updating data in the collectionI and operations for setting and returning the values of different
attributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
![Page 7: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/7.jpg)
Collections
A collection is a structured data type that stores data and providesoperations for adding data to the collection.
Operations include:I removing data from the collection
I updating data in the collectionI and operations for setting and returning the values of different
attributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
![Page 8: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/8.jpg)
Collections
A collection is a structured data type that stores data and providesoperations for adding data to the collection.
Operations include:I removing data from the collectionI updating data in the collection
I and operations for setting and returning the values of differentattributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
![Page 9: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/9.jpg)
Collections
A collection is a structured data type that stores data and providesoperations for adding data to the collection.
Operations include:I removing data from the collectionI updating data in the collectionI and operations for setting and returning the values of different
attributes of the collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 4 / 13
![Page 10: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/10.jpg)
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows theprevious element.
Elements in a linear collection are normally ordered by position (first,second, third, etc.).
Nonlinear collections hold elements that do not have positional orderwithin the collection.
An organizational chart is an example of a non- linear collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
![Page 11: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/11.jpg)
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows theprevious element.
Elements in a linear collection are normally ordered by position (first,second, third, etc.).
Nonlinear collections hold elements that do not have positional orderwithin the collection.
An organizational chart is an example of a non- linear collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
![Page 12: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/12.jpg)
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows theprevious element.
Elements in a linear collection are normally ordered by position (first,second, third, etc.).
Nonlinear collections hold elements that do not have positional orderwithin the collection.
An organizational chart is an example of a non- linear collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
![Page 13: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/13.jpg)
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows theprevious element.
Elements in a linear collection are normally ordered by position (first,second, third, etc.).
Nonlinear collections hold elements that do not have positional orderwithin the collection.
An organizational chart is an example of a non- linear collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
![Page 14: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/14.jpg)
Collection Types
Collections can be broken down into two types: linear and nonlinear.
A linear collection is a list of elements where one element follows theprevious element.
Elements in a linear collection are normally ordered by position (first,second, third, etc.).
Nonlinear collections hold elements that do not have positional orderwithin the collection.
An organizational chart is an example of a non- linear collection.
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 5 / 13
![Page 15: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/15.jpg)
Collection Properties and Methods
Collection Property is the collections Count, which holds the numberof items in the collection.
Collection operations, called methods, include:I Add (for adding a new element to a collection)I Insert (for adding a new element to a collection at a specified index)I Remove (for removing a specified element from a collection)I Clear (for removing all the elements from a collection)I Contains (for determining if a specified element is a member of a
collection)
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
![Page 16: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/16.jpg)
Collection Properties and Methods
Collection Property is the collections Count, which holds the numberof items in the collection.
Collection operations, called methods, include:I Add (for adding a new element to a collection)I Insert (for adding a new element to a collection at a specified index)I Remove (for removing a specified element from a collection)I Clear (for removing all the elements from a collection)I Contains (for determining if a specified element is a member of a
collection)
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
![Page 17: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/17.jpg)
Collection Properties and Methods
Collection Property is the collections Count, which holds the numberof items in the collection.
Collection operations, called methods, include:I Add (for adding a new element to a collection)I Insert (for adding a new element to a collection at a specified index)I Remove (for removing a specified element from a collection)I Clear (for removing all the elements from a collection)I Contains (for determining if a specified element is a member of a
collection)
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 6 / 13
![Page 18: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/18.jpg)
Linear Collections
Direct Access Collections
Sequential Access Collections
Generalized Indexed Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
![Page 19: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/19.jpg)
Linear Collections
Direct Access Collections
Sequential Access Collections
Generalized Indexed Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
![Page 20: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/20.jpg)
Linear Collections
Direct Access Collections
Sequential Access Collections
Generalized Indexed Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
![Page 21: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/21.jpg)
Linear Collections
Direct Access Collections
Sequential Access Collections
Generalized Indexed Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 7 / 13
![Page 22: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/22.jpg)
Struct
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 8 / 13
![Page 23: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/23.jpg)
Non Linear Collections
Hierarchical Collections
Group Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
![Page 24: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/24.jpg)
Non Linear Collections
Hierarchical Collections
Group Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
![Page 25: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/25.jpg)
Non Linear Collections
Hierarchical Collections
Group Collections
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 9 / 13
![Page 26: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/26.jpg)
My Collection Class
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 10 / 13
![Page 27: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/27.jpg)
Generic Programming
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 11 / 13
![Page 28: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/28.jpg)
Oversimplified Timing Tests
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 12 / 13
![Page 29: DSA - Lecture 03](https://reader033.fdocuments.us/reader033/viewer/2022042513/548258b8b47959d80c8b474f/html5/thumbnails/29.jpg)
Charting in .Net
DEMO
Dr.Haitham A. El-Ghareeb (CIS) Data Structures and Algorithms - 2012 September 30, 2012 13 / 13