You are viewing a free preview of this lesson.
Subscribe to unlock all 10 lessons in this course and every other course on LearningBro.
This lesson covers Abstract Data Types (ADTs) — a foundational concept in the OCR A-Level Computer Science (H446) specification. Understanding ADTs is essential for designing clean, modular, and maintainable software.
An Abstract Data Type (ADT) is a logical description of a data structure that defines:
An ADT does not specify how the data is stored or how the operations are implemented. It describes the interface (what you can do) without revealing the implementation (how it is done).
Think of a television remote control:
| Benefit | Description |
|---|---|
| Abstraction | Users interact with the interface, not the implementation. |
| Encapsulation | Implementation details are hidden — changes to the implementation do not affect the user. |
| Modularity | Code is organised into self-contained units that can be developed and tested independently. |
| Reusability | An ADT can be reused in different programs with different implementations. |
| Flexibility | The implementation can be changed (e.g., from an array to a linked list) without changing the code that uses the ADT. |
| Concept | Definition | Example (Stack) |
|---|---|---|
| Interface | The set of operations the ADT provides | push(), pop(), peek(), isEmpty() |
| Implementation | The actual code and data structures used | Array-based, linked list-based |
The same ADT can have multiple implementations:
| ADT | Implementation 1 | Implementation 2 |
|---|---|---|
| Stack | Array-based | Linked list-based |
| Queue | Circular array | Linked list |
| List | Array | Linked list |
| Priority Queue | Sorted array | Binary heap |
| Dictionary | Hash table | BST |
The user of the ADT does not need to know or care which implementation is being used — they just use the defined operations.
| Operation | Description |
|---|---|
| push(item) | Add an item to the top |
| pop() | Remove and return the top item |
| peek() | Return the top item without removing |
| isEmpty() | Return true if the stack is empty |
| size() | Return the number of items |
| Operation | Description |
|---|---|
| enqueue(item) | Add an item to the rear |
| dequeue() | Remove and return the front item |
| front() | Return the front item without removing |
| isEmpty() | Return true if the queue is empty |
| size() | Return the number of items |
| Operation | Description |
|---|---|
| insert(index, item) | Insert item at given position |
| remove(index) | Remove item at given position |
| get(index) | Return item at given position |
| set(index, item) | Replace item at given position |
| contains(item) | Check if item exists in the list |
| size() | Return the number of items |
| isEmpty() | Return true if the list is empty |
| Operation | Description |
|---|---|
| put(key, value) | Add or update a key-value pair |
| get(key) | Return the value associated with the key |
| remove(key) | Remove the key-value pair |
| containsKey(key) | Check if the key exists |
| keys() | Return all keys |
| size() | Return the number of key-value pairs |
| Operation | Description |
|---|---|
| insert(item, priority) | Add an item with a given priority |
| removeHighest() | Remove and return the highest-priority item |
| peekHighest() | Return the highest-priority item without removing |
| isEmpty() | Return true if the queue is empty |
When designing a new ADT, follow these steps:
What information does the ADT need to store?
What actions can be performed on the data? Define each operation with:
What happens when the structure is empty? What about invalid inputs?
Subscribe to continue reading
Get full access to this lesson and all 10 lessons in this course.