Download as pdf or txt
Download as pdf or txt
You are on page 1of 29

CSE 225 Data Structures and Algorithms

Mirza Mohammad Lutfe Elahi

Department of Electrical and Computer Engineering


North South University
Fall 2016

Data Design and Implementation

Chapter 02

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 1 / 13
Data Design and Implementation

What do we mean by Data?

The representation of information in a manner suitable for


communication or analysis by humans or machines.
Data are the nouns of the programming world
The objects that are manipulated
The information that is processed

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 2 / 13
Data Design and Implementation

What do we mean by Data?

The representation of information in a manner suitable for


communication or analysis by humans or machines.
Data are the nouns of the programming world
The objects that are manipulated
The information that is processed

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 2 / 13
Data Design and Implementation

What do we mean by Data?

The representation of information in a manner suitable for


communication or analysis by humans or machines.
Data are the nouns of the programming world
The objects that are manipulated
The information that is processed

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 2 / 13
Data Design and Implementation

What do we mean by Data?

The representation of information in a manner suitable for


communication or analysis by humans or machines.
Data are the nouns of the programming world
The objects that are manipulated
The information that is processed

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 2 / 13
Data Design and Implementation

Data Abstraction

Separation of a data types logical properties from its implementation.

Local Properties Implementation


What are the possible values? How can this be done in C++?
What operations will be needed? How can data types be used?

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 3 / 13
Data Design and Implementation

Data Encapsulation

The separation of the representation of data from the applications that use
the data at a logical level; a programming language feature that enforces
information hiding

Figure: A black box representing an integer


Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 4 / 13
Data Design and Implementation

Abstract Data Type (ADT)

A data type whose properties (domain and operations) are specified


independently of any particular implementation.
To reduce complexity through abstraction, we can protect our data
abstraction through encapsulation.
All possible values (the domain) of an encapsulated data ”object,”
plus the specifications of the operations that are provided to create
and manipulate the data, as an abstract data type (ADT for short).

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 5 / 13
Data Design and Implementation

Abstract Data Type (ADT)

A data type whose properties (domain and operations) are specified


independently of any particular implementation.
To reduce complexity through abstraction, we can protect our data
abstraction through encapsulation.
All possible values (the domain) of an encapsulated data ”object,”
plus the specifications of the operations that are provided to create
and manipulate the data, as an abstract data type (ADT for short).

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 5 / 13
Data Design and Implementation

Abstract Data Type (ADT)

A data type whose properties (domain and operations) are specified


independently of any particular implementation.
To reduce complexity through abstraction, we can protect our data
abstraction through encapsulation.
All possible values (the domain) of an encapsulated data ”object,”
plus the specifications of the operations that are provided to create
and manipulate the data, as an abstract data type (ADT for short).

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 5 / 13
Data Design and Implementation

Data Structures

Figure: A collection of books ordered in different ways


Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 6 / 13
Data Design and Implementation

Data Structures

A collection of data elements whose organization is characterized by


accessing operations that are used to store and retrieve the individual
data elements; the implementation of the composite data members in
an abstract data type.
The library ”data structure” is composed of elements (books) in a
particular physical arrangement;
The physical structure and the abstract picture of the books in the
library are not the same.
The card catalog provides logical views of the library-ordered by
subject, author, or title-that differ from its physical arrangement.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 7 / 13
Data Design and Implementation

Data Structures

A collection of data elements whose organization is characterized by


accessing operations that are used to store and retrieve the individual
data elements; the implementation of the composite data members in
an abstract data type.
The library ”data structure” is composed of elements (books) in a
particular physical arrangement;
The physical structure and the abstract picture of the books in the
library are not the same.
The card catalog provides logical views of the library-ordered by
subject, author, or title-that differ from its physical arrangement.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 7 / 13
Data Design and Implementation

Data Structures

A collection of data elements whose organization is characterized by


accessing operations that are used to store and retrieve the individual
data elements; the implementation of the composite data members in
an abstract data type.
The library ”data structure” is composed of elements (books) in a
particular physical arrangement;
The physical structure and the abstract picture of the books in the
library are not the same.
The card catalog provides logical views of the library-ordered by
subject, author, or title-that differ from its physical arrangement.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 7 / 13
Data Design and Implementation

Data Structures

A collection of data elements whose organization is characterized by


accessing operations that are used to store and retrieve the individual
data elements; the implementation of the composite data members in
an abstract data type.
The library ”data structure” is composed of elements (books) in a
particular physical arrangement;
The physical structure and the abstract picture of the books in the
library are not the same.
The card catalog provides logical views of the library-ordered by
subject, author, or title-that differ from its physical arrangement.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 7 / 13
Data Design and Implementation

Data from Three Different Levels

Application (or user) level: modeling real-life data in a specific


context.
Logical (or ADT) level: abstract view of the domain and operations.
Implementation level: specific representation of the structure to
hold the data items, and the coding for operations.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 8 / 13
Data Design and Implementation

Data from Three Different Levels

Application (or user) level: modeling real-life data in a specific


context.
Logical (or ADT) level: abstract view of the domain and operations.
Implementation level: specific representation of the structure to
hold the data items, and the coding for operations.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 8 / 13
Data Design and Implementation

Data from Three Different Levels

Application (or user) level: modeling real-life data in a specific


context.
Logical (or ADT) level: abstract view of the domain and operations.
Implementation level: specific representation of the structure to
hold the data items, and the coding for operations.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 8 / 13
Data Design and Implementation

Communication between Levels

Figure: Communication between the Application Level and Implementation Level


Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 9 / 13
Data Design and Implementation

Viewing a Library from Three Different Levels

Application (or user) level: Public Library, or NSU Library.


Logical (or ADT) level: domain is a collection of books;
-operations include: check book out, check book in, pay fine, reserve
a book.
Implementation level: representation of the structure to hold the
books, and the coding for operations.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 10 / 13
Data Design and Implementation

Viewing a Library from Three Different Levels

Application (or user) level: Public Library, or NSU Library.


Logical (or ADT) level: domain is a collection of books;
-operations include: check book out, check book in, pay fine, reserve
a book.
Implementation level: representation of the structure to hold the
books, and the coding for operations.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 10 / 13
Data Design and Implementation

Viewing a Library from Three Different Levels

Application (or user) level: Public Library, or NSU Library.


Logical (or ADT) level: domain is a collection of books;
-operations include: check book out, check book in, pay fine, reserve
a book.
Implementation level: representation of the structure to hold the
books, and the coding for operations.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 10 / 13
Data Design and Implementation

Basic ADT Operations

Constructor: creates a new instance (object) of an ADT.


Transformer: changes the state of one or more of the data values of
an instance.
Observer: allows us to observe the state of one or more of the data
values without changing them.
Iterator: allows us to process all the components in a data structure
sequentially.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 11 / 13
Data Design and Implementation

Basic ADT Operations

Constructor: creates a new instance (object) of an ADT.


Transformer: changes the state of one or more of the data values of
an instance.
Observer: allows us to observe the state of one or more of the data
values without changing them.
Iterator: allows us to process all the components in a data structure
sequentially.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 11 / 13
Data Design and Implementation

Basic ADT Operations

Constructor: creates a new instance (object) of an ADT.


Transformer: changes the state of one or more of the data values of
an instance.
Observer: allows us to observe the state of one or more of the data
values without changing them.
Iterator: allows us to process all the components in a data structure
sequentially.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 11 / 13
Data Design and Implementation

Basic ADT Operations

Constructor: creates a new instance (object) of an ADT.


Transformer: changes the state of one or more of the data values of
an instance.
Observer: allows us to observe the state of one or more of the data
values without changing them.
Iterator: allows us to process all the components in a data structure
sequentially.

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 11 / 13
Data Design and Implementation

Composite Data Type

Stores a collection of individual data components under one variable


name;
Allows the individual data components to be accessed.

Unstructured Structured
Components are not organized The organization determines
with respect to one another. method used to access individual
data components.
Examples: classes and structs Examples: arrays

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 12 / 13
Data Design and Implementation

Composite Data Type

Stores a collection of individual data components under one variable


name;
Allows the individual data components to be accessed.

Unstructured Structured
Components are not organized The organization determines
with respect to one another. method used to access individual
data components.
Examples: classes and structs Examples: arrays

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 12 / 13
Data Design and Implementation

C++ Built-in Data Types

Mirza Mohammad Lutfe Elahi (ECE@NSU) C++ Plus Data Structures, Nell Dale (5th) Chapter 02 13 / 13

You might also like