Abstract Data Type algorithm brief Description with example
The abstract data type is a triangle of D-set of domains, F-set of functions, A- axioms in which only what is to be done is mentioned but is to be done not mentioned.
In ADT, all the implementation details are hidden. In short ADT = Type + Function names + Behavior of each function
The concept at abstraction is commonly found in computer science. A big problem is never written as a monolithic piece of the program, instead, it is broken down in smaller modules (may be called a function or procedure) and each module is developed independently.
When the program is hierarchically organized as shown in below figure, then the main program utilizes services at the functions appearing at level 1. Similarly, the function written at level 1 utilizes services of functions written at level 2. Main program
Uses the services at the next level function without knowing their implementation details. Thus a level of abstraction is created. When an abstraction is created at any level, our concern is limited to “what it can do” and not “how it is done”.
Abstraction in cases of data
Abstraction for primitive types (char, int, float) is provided by the compiler.
For example, we use integer type data and also, perform various operations on them without knowing them: 1) Representation 2) How various operations are performed on them?
Meaning of the operation ‘+’ is defined by the compiler and its implementation details remain hidden from the user.
Implementation details and how various operations are implemented remain hidden from the user. A user is only concerned about, how to use these operations.
An object such as lists, sets, and graphs along with associated operations, can be viewed as abstract data type, integer, char, real are primitive data types and there are set of operations associated with them. For the set ADT (Abstract Datatype).
The abstract Data type “List”
A list is a sequence of O or more elements of a given type (element type, could be integer, float etc.) Such a list is often represented as: a1, a2……………..an
n = number of elements in the list
ai = ith element of the list
when n=0, the list is empty having no element
each element other than a1 has a predecessor
each element, other than an has a successor.
In order to form an ADT from the mathematical notation of a list, we must represent the list and define a set of operations on the object of type list. Representation of a List
A list can be represented in ‘C’ using a structure type list
A list of the maximum of 50 integer type elements
Here, in the example n is the actual number of elements in the list