Abstract Data Types
🧠 Abstract Data Types (ADTs)
“An abstract data type defines behavior, not implementation.”
— Core CS principle
🔍 What is an Abstract Data Type?
An Abstract Data Type (ADT) is a conceptual model of a data structure — it
describes what a structure does, not how it does it.
You can think of ADTs as interfaces between your mind and the machine.
For example:
A stack is an ADT that supports:
push(item) → Add item on top
pop() → Remove item from top
It doesn't matter whether it's implemented using an array, a linked list, or even a
dynamic memory block. What matters is how it behaves.
🧰 Examples of ADTs
ADT Description Real-world analogy
Stack LIFO (Last-In, First-Out) Stack of trays
Queue FIFO (First-In, First-Out) Line at a movie theater
List Ordered collection Playlist or to-do list
Deque Double-ended queue (push/pop Train cars that can be added/removed
at both ends) at both ends
Map Key-value pairs Dictionary or phonebook
Set Unordered, unique items Collection of unique stamps
Graph Nodes and edges Social network, road map
ADT Description Real-world analogy
Tree Hierarchical data Company org chart or file system
🧠 Why Do ADTs Matter?
Separation of concerns: You can focus on how you use the data structure, not
how it's built.
Multiple implementations: A Stack can be implemented using:
Arrays (fixed or dynamic)
Linked Lists
Algorithm design: Many algorithms depend on ADT behaviors rather than actual
data layout.
Interface-first thinking: Helps in designing reusable and modular code.
💡 Key Insight
Think of ADTs like contracts:
They promise certain behaviors (insert, delete, search, etc.).
As long as the contract is fulfilled, the underlying mechanism can vary.
//
Abstra
ct
interf
ace of
a
stack
in C-
style
pseudo
code
stack s = create_stack();
push(s, 10);
int x = pop(s);