Data Structures - Abstract Data Types (ADTs)
Abstract Data Type (ADT) is a way of looking at a data structure. To handle the complex problems, the computer programmer use abstraction to focus on what it does and ignoring how it does its job. ADTs are purely theoretical entities, used to simplify the description of algorithms, used to classify and evaluate the data structures.
Write Once. Run Many Times
When there were no ADTs, if we wanted to read a file, we wrote the code to read the file from drive. Unfortunately this code did not live longer. Some other time, if we needed to read the same file, then we were writing the code again and again. To overcome this, we created what is known today is Abstract Data Types. With ADTs, we write the code once and place it in a library for all programmers to use. Most popular programming languages have libraries created for Abstract Data types which can be used in software that we create.
Basic rule for programming is that a routine should not ever exceed a page. This is achieved by breaking the program down into modules. Each module is a logical unit and can perform a specific job. ADTs can be viewed as a modular design.
Advantages of Modularity
- Easier to debug small routines than large routines.
- Easier for several people to work on modular code.
- Program places certain dependencies in only one routine so that we can easily make the changes.
What is ADT?
An abstract data type (ADT) is a set of operations. Abstract data types are defined as a mathematical model of data objects that make up a data type as well as the functions that operate on the objects. Objects such as lists, stacks, trees and graphs, along with their operations, can be viewed as an abstract data types. ADT allows the programmers to use the functions while hiding the implementation details.
More About ADT
- ADT consists of data structures and operations that can be performed on the data structures.
- ADT allows the user to read data structure and also convert it into another data structure.
- With ADT, users are not concerned with how the task is done rather they need to be concerned only with what it can do.
- Basic idea is that the implementation of operations is written once and that can be used again and again in our program.