we depend only on the function's specification, a written description of what it does. We can use the function without having to know its implementation (the algorithms that accomplish the result). By invoking the sqrt function, our program is less complex because all the details involved in computing square roots are absent.
Abstraction techniques also apply to data. Every data type consists of a set of values (the domain) along with a collection of allowable operations on those values. In Chapter 14, we described data abstraction as the separation of a data type's logical properties from its implementation details. Data abstraction comes into play when we need a data type that is not built into the programming language. We can define the new data type as an abstract data type (ADT), concentrating only on its logical properties and deferring the details of its implementation.
Abstract Data Type A data type whose properties (domain and operations) are specified independently of any particular implementation.
As with control abstraction, an abstract data type has both a specification (the what) and an implementation (the how). The specification of an ADT describes the characteristics of the data values as well as the behavior of each of the operations on those values. The user of the ADT needs to understand only the specification, not the implementation, in order to use it. Here's a very informal specification of a list ADT:
TYPE
IntList
DOMAIN
Each IntList value is a collection of up to 100 separate integer numbers.
OPERATIONS
Insert an item into the list.
Delete an item from the list.
Search the list for an item.
Return the current length of the list.
Sort the list into ascending order.
Print the list.
Notice the complete absence of implementation details. We have not mentioned how the data might actually be stored in a program (for example, in an array) or how the operations might be implemented. Concealing the im-