What is Abstract Datatype || how to define abstract datatypes || ADT || use of Abstract datatype(ADT)
What is Abstract Datatype(ADT)?
In order to understand Abstract Datatype, first of all lets understand what is datatype and what are its properties.
Datatype defines representation and operations of data stored. For example we declare integer datatype which contains 2 bytes(16 bits) in memory. As this data is type of integer certain operations are allowed like addition, subtraction, multiplication, division, modulo, increment, decrement. A datatype has two properties, first representation of data and operations can be performed.
let’s take an example of list. We don’t have pre-defined datatype for representation of a list so we need to create our own datatype. This requires space in memory, total capacity of list and size of list (number of elements present in list). This list has some operations to make on a list like add or append, insert, remove, search for element/elements, sort and many more.
Now we have representation of data and operations on data which are properties of a datatype. This all things can be put together and defined in a class. When I want to use this list datatype, I have to simply create an object of that class and treat it as a datatype, I don’t need to worry how things are working internally. This kind of datatype is called Abstract Datatypes.
Abstract datatypes are very useful feature of object-oriented programming which enables reusability of code.
Comments
Post a Comment