An ADT in one sentence
An abstract data type (ADT) is a model of data defined by its operations and behavior, not by how it is stored. You can say what a stack does, such as push and pop, without saying whether it uses an array or a linked list.
What an ADT specifies
A complete ADT definition covers:
- The kinds of values it holds, such as integers, strings or records.
- The operations it allows, such as add, remove, search or count.
- What each operation does, including what it returns and how it changes the data.
- The error cases, such as trying to remove an item from an empty collection.
Take a queue. Its ADT says that enqueue adds an item to the back, dequeue removes and returns the item at the front, and items leave in the order they arrived. Those rules are the definition. They don’t mention memory, pointers or indexes.
Why the implementation stays hidden
Callers of an ADT depend on its operations, not its internals. If a program only calls push and pop, the stack underneath can change from an array to a linked list, and the calling code keeps working. This separation is called information hiding, and it is one of the main reasons the ADT idea matters.
Barbara Liskov and Stephen Zilles described the approach in a 1974 paper on programming with abstract data types. Their work helped bring the idea into programming language design.
Common ADTs
| ADT | Main operations | Typical rule |
|---|---|---|
| List | add, get by position, remove | items keep their order |
| Stack | push, pop, top | last in, first out |
| Queue | enqueue, dequeue, front | first in, first out |
| Set | add, remove, contains | each item appears once |
| Map (dictionary) | put, get, remove by key | each key maps to one value |
| Priority queue | insert, remove highest priority | the top item has the highest priority |
Each row is a definition that can be built in several ways.
How an ADT gets implemented
An ADT is usually built on top of one or more data structures:
- A stack can use an array or a linked list.
- A map can use a hash table, which gives average constant-time lookups, or a balanced search tree, which keeps keys in sorted order and gives logarithmic lookups. An AVL tree in data structure courses is one example of a balanced tree.
- A priority queue is often built on a binary heap.
The choice affects speed and memory use. The ADT stays the same.
ADTs in code
Many languages let you express an ADT as an interface or an abstract class. Java’s List interface is one example: code written against List can take an ArrayList or a LinkedList without changes. C++ uses abstract classes with pure virtual functions for the same purpose. Some languages, such as Python, rely on duck typing, where any object with the right methods works.
In these settings, “abstract” means the details are left out of the definition. That is not the same as the abstract keyword in Java or C#.
Common mistakes
- Confusing “abstract” with “abstract class”. The ADT is about hiding details. An abstract class is one language tool for writing an interface.
- Thinking an ADT is a keyword. Most languages don’t have an “ADT” type. You define the ADT as a set of operations, then implement it.
- Treating the ADT as the memory layout. The layout belongs to the data structure. An ADT doesn’t say where items sit in memory.
Summary
- An ADT defines values, operations and behavior.
- It doesn’t say how the data is stored.
- The same ADT can be implemented with different data structures, each with different trade-offs.
- Common ADTs include list, stack, queue, set, map and priority queue.