Data Structures

H446 · 1.4 Data Types & Structures · A-Level Computer Science

Component 01

Data Structure Overview

StructureAccessInsertDeleteSpaceKey Feature
Array (static)O(1)O(n)O(n)O(n)Fixed size; random access by index
Linked ListO(n)O(1)*O(1)*O(n)Dynamic; no random access; pointers
StackO(1)O(1)O(1)O(n)LIFO; push/pop from one end only
QueueO(1)O(1)O(1)O(n)FIFO; enqueue rear, dequeue front
BSTO(log n)*O(log n)*O(log n)*O(n)Sorted; in-order traversal gives sorted output
Hash TableO(1)*O(1)*O(1)*O(n)Fastest average; needs collision handling
Graph (adj. matrix)O(1)O(1)O(1)O(V²)Fast edge lookup; wastes space for sparse graphs
Graph (adj. list)O(deg)O(1)O(deg)O(V+E)Space efficient for sparse graphs

* Average case — worst case may differ (e.g. unbalanced BST degrades to O(n))

Stack & Queue Simulator

Stack (top → bottom)

Binary Search Tree Builder

Insert values one at a time. Left subtree < node < right subtree. Click "In-order Traversal" for sorted output.

Linked List Structure

Each node contains a data value and a pointer to the next node. Dynamic — grows/shrinks at runtime. No random access.

42

→ next

17

→ next

93

→ None

Advantages

  • Dynamic size — grows as needed
  • Efficient insert/delete at head: O(1)
  • No wasted memory allocation

Disadvantages

  • No random access — O(n) to find element
  • Extra memory for each pointer
  • Poor cache performance (not contiguous)