130 likes | 305 Views
ENEE150 Discussion 4/24: Abstract Data Types. Introduction to Abstract Data Types. In every language, we have a set of primitive data types, such as long, int , char, etc. Using these simple data types, we can construct complex data structures to represent our information.
E N D
Introduction to Abstract Data Types • In every language, we have a set of primitive data types, such as long, int, char, etc. • Using these simple data types, we can construct complex data structures to represent our information
A first look an ADTs • Solving a problem involves processing data, and an important part of the solution is the careful organization of the data • In order to do that, we need to identify: • The collection of data items • Basic operation that must be performed on them • Abstract Data Type (ADT): a collection of data items together with the operations on the data
Abstract Data Types • A user defined data type, often complex in nature, with a strong separation of use and implementation • Attributes: • A representation of some data • A set of operations on the representation
Benefits: • With a well defined interface, we can create a strong separation of use from implementation • Interface is an important part of the ADT, in order to separate out the implementation from the client, who simply needs to know how to use the data type
Abstract Data Type (ADT) • The word “abstract” refers to the fact that the data and the basic operations defined on it are being studied independently of how they are implemented • We think about what can be done with the data, not how it is done
Examples: • Complex Numbers • Rational Numbers • Linkedlists
Implementation of ADT • An implementation of ADT consists of storage structures to store the data items and algorithms for basic operation
Data Structures, Abstract Data Types, and Implementations • Consider example of an airplane flight with 10 seats to be assigned • Tasks • List available seats • Reserve a seat • How to store, access data?
Data Structures, Abstract Data Types, and Implementations • Consider example of an airplane flight with 10 seats to be assigned • Tasks • List available seats • Reserve a seat • How to store, access data? • 10 individual variables
Data Structures, Abstract Data Types, and Implementations • Consider example of an airplane flight with 10 seats to be assigned • Tasks • List available seats • Reserve a seat • How to store, access data? • 10 individual variables • An array of variables
ADTs • In this simple example, it does illustrate the concept of an Abstract Data Type • ADT consists of • The collection of data items • Basic operation that must be performed on them • In the example, a collection of data is a list of seats • The basic operations are (1) Scan the list to determine which seats are occupied (2) change seat’s status