Show understanding that an ADT is a collection of data and a set of operations on those data

Published by Patrick Mutisya · 14 days ago

Cambridge A-Level CS 9618 – 10.4 Introduction to Abstract Data Types (ADT)

Introduction to Abstract Data Types (ADT)

An Abstract Data Type (ADT) is a formal description of a set of data values together with a set of operations that can be performed on those values. The ADT specifies what operations are available and the behaviour of those operations, but not how they are implemented.

Key Concepts

  • Data Set – the collection of values that the ADT can hold.
  • Operations – functions or methods that manipulate the data set.
  • Specification – the contract that defines the behaviour of operations.
  • Implementation – a concrete data structure that satisfies the specification.

Examples of ADTs

  1. Stack – LIFO (Last In, First Out) structure.
  2. Queue – FIFO (First In, First Out) structure.
  3. List – ordered collection with indexed access.
  4. Set – unordered collection of unique elements.
  5. Map (Dictionary) – key–value pairs with unique keys.

Operations on ADTs

Operations are defined by the ADT specification. For a Stack ADT the typical operations are:

OperationParametersReturnsDescription
pushvaluevoidAdds value to the top of the stack.
popnonevalueRemoves and returns the top element.
peeknonevalueReturns the top element without removing it.
isEmptynonebooleanChecks whether the stack contains no elements.

The behaviour of these operations can be expressed mathematically. For example, if S denotes the stack state and v a value, then:

\$\text{push}(S, v) = S \cup \{v\}\$ (with v at the top)

\$\text{pop}(S) = (v, S')\$ where v is the top element and S' is the remaining stack.

ADT vs Concrete Implementation

ADTConcrete ImplementationTypical OperationsKey Properties
StackArray, Linked List, Dynamic Arraypush, pop, peek, isEmptyLast In, First Out; O(1) amortised for array implementation.
QueueArray, Circular Buffer, Linked Listenqueue, dequeue, front, isEmptyFirst In, First Out; O(1) for circular buffer.
SetHash Table, Binary Search Treeadd, remove, contains, sizeUnique elements; average O(1) for hash table.
MapHash Table, Binary Search Treeput, get, remove, containsKey, sizeKey–value pairs; average O(1) for hash table.

Suggested Diagram

Suggested diagram: Flow of operations on a Stack ADT – showing push, pop, and peek actions relative to the stack top.