What is an Abstract Data Type (ADT)?
You'll learn: What an Abstract Data Type (ADT) is and why it separates what operations do from how they're implemented.
The Core Idea
An Abstract Data Type (ADT) is like a blueprint or contract that describes what a data structure can do, without specifying how it does it. It defines a set of operations (like "add an item," "remove an item," "check if empty") but leaves the implementation details hidden.
Think of it like a car's interface: you know you can steer, accelerate, and brake, but you don't need to know whether the engine is electric or gasoline-powered. The ADT is the steering wheel and pedals—the interface. The actual engine is the implementation.
Why ADTs Matter
ADTs separate interface from implementation:
- Interface: The operations you can perform and what they promise to do
- Implementation: The underlying data structure (array, linked list, etc.) and algorithms used
For example, a "List ADT" might define operations like insert, delete, and search. You could implement this using:
- An array
- A singly linked list
- A doubly linked list
All three implementations satisfy the same ADT contract, but work differently under the hood.
Benefits
- Flexibility: Swap implementations without changing code that uses the ADT
- Clarity: Users focus on what operations do, not how
- Encapsulation: Hide complexity behind a clean interface
In upcoming lessons, you'll see Stacks and Queues—both are ADTs with simple, well-defined operations that can be implemented in multiple ways.
Key Takeaway: An ADT is an interface defining what operations a data structure supports, independent of how those operations are implemented.