← IB Computer Science

Stacks, queues and linked lists

Topic B4 (Abstract data types) is Higher Level only. This unit introduces what an ADT is and how it differs from a data structure, then looks at three building blocks: the stack (last-in, first-out), the queue (first-in, first-out) and the linked list (a chain of nodes joined by pointers). Get comfortable with the operations of each, because the rest of B4 builds on them.

Slide 1 / 4

Abstract data types vs data structures

One ADT, different data structures ADT: Stack what you can do (the interface) push() · pop() · peek()isEmpty() reached only through these operations (encapsulation) implemented by Data structure: array 3 7 1 Data structure: linked nodes 3 7 1 Swap the implementation without changing code that uses the ADT.
  • An abstract data type (ADT) describes what you can do with data (its operations and behaviour) without saying how it is stored or implemented.
  • A data structure is the concrete way the data is actually held in memory, such as an array or a set of linked nodes.
  • The same ADT can be built on different data structures, so the implementation can be swapped without changing the code that uses it (modularity and reusability).
  • ADTs give abstraction and encapsulation: the data can only be reached through the defined operations, which hides complexity and prevents misuse.

Check you've got it

0/4

1. Which statement best describes the difference between an abstract data type (ADT) and a data structure?

2. You push 3, then 7, then 5 onto an empty stack, then perform two pop operations. What value does the SECOND pop return?

3. You enqueue 4, then 8, then 2 into an empty queue, then perform one dequeue. Which value is removed?

4. In a singly linked list (not circular), what does the pointer of the tail (last) node point to?

Free revision content. Multiple-choice answers are marked instantly. Written answers are marked by AI on /free-mark.