Data Structures

B2.2 - Data structures


Overview

Every program needs to store collections of data. This section covers fundamental data structures: from simple arrays to abstract structures like stacks and queues.

# Topic Syllabus Key Concepts Level
1 1D Arrays B2.2.2 Static structure; fixed size, direct index access SL + HL
2 2D Arrays B2.2.2 Static structure; rows and columns (grid/table) SL + HL
3 ArrayList B2.2.2 Dynamic structure; grows and shrinks automatically SL + HL
4 Stacks B2.2.3 Abstract structure; Last In, First Out (LIFO) SL + HL
5 Queues B2.2.4 Abstract structure; First In, First Out (FIFO) SL + HL

Choose a topic above for worked examples, quizzes and practice exercises.


Choosing the Right Structure

Situation Best choice
Fixed number of items, fast index access Array
Number of items changes at runtime ArrayList
Need LIFO (undo, backtracking) Stack
Need FIFO (order matters, job queue) Queue
Tabular data (grid, board, matrix) 2D Array

Static vs Dynamic Structures

Feature Static (Array) Dynamic (ArrayList; Java’s Stack and LinkedList queue)
Size Fixed at creation Grows or shrinks at runtime
Memory Allocated once Allocated as needed
Access Direct by index Depends on type
Speed Very fast Slight overhead

The key insight: static structures are simpler and faster when you know the size in advance. Dynamic structures are necessary when size changes at runtime.


Table of contents


© EduCS.me. A resource hub for Computer Science education. EduCS is an independent educational resource. It is not affiliated with, or endorsed by, the International Baccalaureate Organization. Contact