Abstract Data Types
Definitions
- Abstract data types or ADTs are a mathematical specification of a set of
data and the set of operations that can be performed on the data.
- We think of an abstract data type as a type defined in terms of its behavior
rather than its implementation.
-
Technically, we define an abstract data type as a mathematical object
and the operations on that object.
Example :
Strings
ADT
A string is a group of characters that are thought of as a single
object.
The operations on strings include :
- finding its length
- concatenation
- copying one string into another
- comparing two strings for equality or for alphabetic ordering
- etc.
Implementation of a string:
A string in C is an array of characters that is pointed to by a pointer
whose variable name is the name of the array. The string can be indexed
like other arrays. A string is special, because its last character has
to be the null terminator.
Strings have many operations on them. Those operations have been written
for us and are found in the string library.