0% found this document useful (0 votes)
81 views15 pages

Abstract Data Types: Asim Rehan

The document discusses abstract data types, which define a data type solely based on the values and operations without specifying implementation details. An abstract data type consists of data structures to store data and algorithms to perform basic operations on that data. Data structures provide the physical implementation of an abstract data type by defining how data is stored in memory and organizing related data items and operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
81 views15 pages

Abstract Data Types: Asim Rehan

The document discusses abstract data types, which define a data type solely based on the values and operations without specifying implementation details. An abstract data type consists of data structures to store data and algorithms to perform basic operations on that data. Data structures provide the physical implementation of an abstract data type by defining how data is stored in memory and organizing related data items and operations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Abstract Data Types

Asim Rehan

1
Some basic questions

• What is an integer?
– What are the operations that can be performed on
Integers?

• What is a character?
– What are the operations that can be performed on
characters?
Some more basic questions
• How an integer is represented?
– How the integer based operations are performed?

• How a rational number is represented?


• How different operations are performed?

• Primitive Data types vs non-primitive


– Saved directly. Non-primitive uses primitive.
Abstraction levels
• What are different kinds of programming
Languages?
– Low-level/Assembly/High-level languages

• Programming in a certain type of language


involves abstraction
– In order to simplify the representation
– In order to make it easier to program
Abstraction levels
• While programming in a high-level language we
are not that bothered about low level
representation
Abstract Data Types
• Abstract data-types allow us to take our
abstraction level, one-step further

• Instead of focusing on how a particular data-


structure can be implemented, focus is on what
should be chosen to solve the problem
Abstract Data Types
• Abstract Data Type (ADT): a definition for a data type
solely in terms of a set of values and a set of operations
on that data type.

• Each ADT operation is defined by its inputs and outputs.


– Hide Implementation details (Encapsulation !)

7
Abstract Data Types
Def.
a collection of related data items
together with
an associated set of operations
e.g. whole numbers (integers)
Basic Operations: apply arithmetic operations (addition,
subtraction, multiplication and division)

e.g. Flight reservation


Basic Operations: find empty seat, reserve a seat,
cancel a seat assignment

Why "abstract" ?
Data, operations, and relations are studied independent of
implementation.

What not how is the focus.


8
Abstract Data Types
Def. Consists of
storage structures (data structures) to store the
data items
and
algorithms for the basic operations

The storage structures/data structures used in implementations


are provided in a language (primitive or built-in) or are built
from the language constructs (user-defined).

In either case, successful software design uses data abstraction


•Separating the definition of a data type from its
implementation.

9
Data Structure
• A data structure is the physical implementation of an
ADT.
– Each operation associated with the ADT is implemented by one
or more subroutines in the implementation.

• Data structure usually refers to an organization of data


in main memory.

• File structure is an organization for data on peripheral


storage, such as a disk drive.

10
Data Type

ADT:
Data Items:
Type
Logical Form
Operations

Data Structure: Data Items:


Storage Space Physical Form
Subroutines

11
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
Use 10 individual variables
• Algorithm to List available seats • Algorithm to Reserve a seat

1. If seat1 == „ ‟: 1. Set DONE to false


2. If seat1 ==„ ‟:
display 1 print “do you want seat #1??”
2. If seat2 == „ ‟: Get answer
display 2 if answer==„Y‟:
. set seat1 to „X‟
set Done to True
. 3. If seat2 ==„ ‟ and Done == false:
. print “do you want seat #2??”
10. If seat10 == „ ‟: Get answer
if answer==„Y‟:
display 10 set seat2 to „X‟
set Done to True
.
.
.
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

You might also like