PCCST303 · Module 1: Basic Concepts of Data Structures
Abstract Data Type (ADT)
Introduction
Think of the contacts app on your phone.
It stores data: names, phone numbers, email addresses. It gives you operations: add contact, delete contact, search by name.
Each operation has a defined behaviour. Add saves a new contact. Delete removes an existing one. Search finds a contact by name.
You use these operations without knowing how contacts are stored inside the phone's memory. That internal detail is hidden from you.
This is the idea behind an ADT: define what data is stored and what the operations do, without specifying how they are implemented.
Definition
An Abstract Data Type (ADT) is a logical description of a data type defined by its data and the operations on that data, without specifying how either is implemented.
Example: Stack ADT
A stack (covered in detail in a later lesson) stores a collection of elements. It supports these operations:
push(x) -> insert element x onto the stack
pop() -> remove and return the top element
peek() -> return the top element without removing it
isEmpty() -> return true if the stack has no elementsThe Stack ADT does not say whether to use an array or a linked list internally. Both can implement it. The ADT is only the specification, not the construction.
ADT vs implementation
An ADT describes what operations exist and what behaviour they provide. It says nothing about how they are implemented.
| ADT | Implementation |
|---|---|
| Describes behaviour | Describes actual mechanism |
| Specifies operations | Specifies data representation and code |
| Hides implementation | Exposes implementation to the developer |
| Example: Stack | Example: Array stack / linked stack |
Key Idea
ADT = WHAT. Implementation = HOW. This distinction is one of the most important foundations for understanding data structures.
Quick recall
- An ADT defines data and operations, not implementation.
- The Stack ADT specifies push, pop, peek, and isEmpty, without saying how they are built.
- ADT describes behaviour; implementation describes the actual mechanism and code.