B2.2 Data structures: notes and practice
B2.2 covers storing many values: one and two dimensional arrays or lists, stacks, queues, dictionaries and the difference between static and dynamic structures.
Paper 2SL and HL46 practice questions
What you need to know
Our summary of the topic in our own words, not the IB guide.
- Distinguish static from dynamic data structures
- Compare static and dynamic structures on memory use, flexibility and access speed
- Choose a static or dynamic structure for a described scenario and justify it
- Create, index, update and iterate over a one-dimensional array or list
- Write code that searches or accumulates over a list
- Create and traverse a two-dimensional array or list, including by row and by column
- Trace code that manipulates an array or list and state the final contents
- Explain the last in, first out behaviour of a stack and name its operations
- Trace a sequence of push and pop operations and state the stack contents at the end
- Identify a problem that a stack solves naturally and explain why
- Explain the first in, first out behaviour of a queue and name its operations
- Trace a sequence of enqueue and dequeue operations and state the queue contents at the end
- Identify a problem that a queue solves naturally and explain why
- Use a dictionary or map to store and retrieve values by key
Learn it
- Create a list; index; length
Lesson with 5 exercises
- Update, add, remove
Lesson with 5 exercises
- Loop over a list two ways
Lesson with 5 exercises
- Accumulate over a list
Lesson with 4 exercises
- Search a list; find the largest without built-ins
Lesson with 3 exercises
- Trace list code and state the final contents
Lesson with 3 exercises
- Fixed-size arrays versus growable lists
Lesson with 2 exercises
- Two-dimensional lists: rows and columns
Lesson with 4 exercises
- Stack: push, pop, last in first out
Lesson with 5 exercises
- A problem a stack solves
Lesson with 2 exercises
- Queue: enqueue, dequeue, first in first out
Lesson with 3 exercises
- A problem a queue solves
Lesson with 2 exercises
- Capstone: read record lines, split, report
Lesson with 1 exercise
Practice questions
Original questions written for the 2027 course, marked as you go. Easiest first.
- Count above a limitCoding · Warm-up
- Full array of timesWritten · Warm-up
- Last valueCoding · Warm-up
- Queue in wordsWritten · Warm-up
- Stack in wordsWritten · Warm-up
- Trace: list indexTrace table · Warm-up
- Trace: list index (Java)Trace table · Warm-up
- The averageCoding · Core
- Count up in a listCoding · Core
- Down the diagonalCoding · Core
- Double every valueCoding · Core
- First repeat in a rowCoding · Core
- Position of the largestCoding · Core
- Messages sent offlineWritten · Core
- Middle valueCoding · Core
- Move the first to the endCoding · Core
- Seats or waiting listWritten · Core
- Largest minus smallestCoding · Core
- What is left on the stackCoding · Core
- Swap the endsCoding · Core
- Tasks on holdWritten · Core
- Trace: double loopTrace table · Core
- Trace: double loop (Java)Trace table · Core
- Trace: list changesTrace table · Core
- Trace: list changes (Java)Trace table · Core
- Trace: queue movesTrace table · Core
- Trace: queue moves (Java)Trace table · Core
- Trace: running totalTrace table · Core
- Trace: running total (Java)Trace table · Core
- Trace: stack movesTrace table · Core
- Trace: stack moves (Java)Trace table · Core
- Is it an index?Coding · Core
- Do the brackets match?Coding · Stretch
- Trace table: bracket checker with a stackTrace table · Stretch
- Biggest riseCoding · Stretch
- Where it appearsCoding · Stretch
- Questions everyone got rightCoding · Stretch
- Take turns on the consoleCoding · Stretch
- The top of a small stackCoding · Stretch
- Trace: carry largerTrace table · Stretch
- Trace: carry larger (Java)Trace table · Stretch
- Trace: column totalsTrace table · Stretch
- Trace: column totals (Java)Trace table · Stretch
- Trace: swap passTrace table · Stretch
- Balanced bracketsCoding · Stretch
- Warmest dayCoding · Stretch
Exam tips for B2.2
- Draw the structure after each operation when tracing a stack or a queue.
- For a 2D list, be clear whether you loop by row first or by column first.
- Explain why a stack suits undo or bracket matching and a queue suits waiting in order.
Updated 24 October 2026. Topic codes are used as labels. Everything on this page is written by ExamSpine and is not endorsed by the IB.