ADT from ADT (Cambridge (CIE) A Level Computer Science): Revision Note

Exam code: 9618

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Updated on

ADT from ADT

What does it mean?

  • You should be able to explain or demonstrate how you can build one abstract data type on top of another

  • For example:

    • A stack can be implemented using a linked list

    • A queue can be implemented using two stacks

    • A dictionary can be implemented using a binary search tree

  • You’re not just limited to built-in types like arrays, you can compose ADTs out of each other

What is an ADT?

How are ADTs implemented?

Using built-in types (e.g. arrays, lists)

ADT

Built-in type used

Example

Stack

List/array

Use .append() and .pop() in Python

Queue

List/array or circular buffer

Use .append() and .pop(0)

Linked list

Class with next fields

Implement nodes manually

Dictionary

Hash table (built-in dict)

Key-value mapping

Binary tree

Class with left and right

Each node links to children

Using other ADTs

ADT being built

Uses this ADT

Example

Queue

Two stacks

Enqueue in one stack, dequeue using a second stack

Stack

Linked list

Push/pop from head of list

Binary tree

Linked list or array

Nodes link to each other like a graph

Dictionary

Binary search tree

Store keys and values in BST for ordered lookup

Example: Implementing a Queue using Two Stacks

Idea:

  • Use two stacks (let’s say inStack and outStack) to simulate a queue

How it works:

  • enqueue(x) → push x onto inStack

  • dequeue() → if outStack is empty, pop all items from inStack and push onto outStack, then pop from outStack

  • This simulates FIFO behaviour using LIFO operations from stacks

You've read 0 of your 5 free revision notes this week

Unlock more, it's free!

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Robert Hampton

Author: Robert Hampton

Expertise: Computer Science Content Creator

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.

James Woodhouse

Reviewer: James Woodhouse

Expertise: Computer Science & English Subject Lead

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.