Professional Documents
Culture Documents
CHAPTER 1 (Contd..)
Ankita R Karia
The term abstract data type refers to the basic mathematical concept that defines the data type.
Its definition is not concerned with implementation details. It is an useful tool for specifying the logical properties of a data type.
A data structure is a physical implementation of an ADT. Each ADT operation is defined by its inputs and outputs.
18-Dec-12 Ankita R Karia 2
An ADT consists of TWO parts:1. Value Definition:Defines the collection of values for the ADT. It consists of two parts: Definition Clause. Condition Clause.
2. Method Definition:It defines the various functions. Each method is defined with three parts:-
EXAMPLE OF ADT
Consider the ADT RATIONAL which corresponds to the mathematical concept of rational number. Operations that can be performed on rational number are:
Creation of rational number. Addition of two rational number. Multiplication. Test for equality.
Initial Specification of ADT:abstract class RATIONAL <integer, integer> { Definition Clause condition RATIONAL[1]!=0;
STATES THAT RATIONAL CONSISTS OF TWO integers
Condition Clause
VALUE DEFINITION
abstract RATIONAL add (RATIONAL a, RATIONAl b) postcondition add[1] = = a[1]*b[1]; add[0] = = a[0]*b[1] + b[0]*a[1];
abstract RATIONAL mult (RATIONAL a, RATIONAl b) postcondition mult[0] = = a[0]*b[0]; mult[1] = = a[1]*b[1];
ARRAY as an ADT
Let ARRTYPE (ub,elType) denote the ADT corresponding to the JAVA array of the type elType array[ub];
Any data type
int x[10].