Resources | Subject Notes | Computer Science
An Abstract Data Type (ADT) is a mathematical model that defines a set of data and the operations that can be performed on that data. It focuses on what the data represents and what operations are available, without specifying how these operations are implemented.
Consider a list ADT. It can be defined as a collection of ordered elements.
Operation | Description | Precondition | Postcondition |
---|---|---|---|
CreateList() | Creates an empty list. | None | Returns an empty list. |
Insert(element, position) | Inserts an element at a specified position in the list. | position is a valid index within the list. | The element is added to the list at the specified position. |
Delete(position) | Deletes the element at a specified position in the list. | position is a valid index within the list. | The element at the specified position is removed from the list. |
Get(position) | Returns the element at a specified position in the list. | position is a valid index within the list. | Returns the element at the specified position. |
Size() | Returns the number of elements in the list. | None | Returns the number of elements in the list. |
The list ADT defines what a list is and what operations are possible. The actual implementation of the list (e.g., using an array or a linked list) is hidden from the user. Different implementations can exist as long as they provide the same interface.
$$ \text{ADT List} = \text{Data} + \text{Operations} $$
Where: