Welcome to Paper 2: The "Problem Solver’s" Guide

If Paper 1 is about knowing how computers work, Paper 2 is about showing that you can actually use them to solve problems. This paper focuses entirely on Theme B: Computational thinking and problem-solving. Whether you are an SL or HL student, this is where you demonstrate your ability to think like a programmer and write actual code in either Java or Python.

Don't worry if coding feels intimidating! This chapter will break down the specific skills you need to tackle Paper 2 questions with confidence, from breaking down a big problem to writing the final lines of a solution.

1. Understanding the Paper 2 Landscape

Before we dive into the "how," let’s look at the "what." Paper 2 is structured differently depending on your level:

  • Standard Level (SL): 1 hour 15 minutes. Focuses on Topic B.1 (Computational Thinking), Topic B.2 (Programming), and Topic B.3 (OOP).
  • Higher Level (HL): 2 hours. Covers everything SL does, but includes much deeper questions on Topic B.3 (OOP) and introduces Topic B.4 (Abstract Data Types).

Important Note: In Paper 2, you must choose one language: Java or Python. The exam paper will provide the same question in both languages; you simply pick the version that matches what you have studied and stick with it!

2. The Computational Thinking Process (B.1)

The IB defines a specific four-step process for solving problems. You might be asked to describe these steps or apply them to a scenario.

Step 1: Specification
This is about defining the "what." What is the problem? What are the success criteria? (e.g., "The program must calculate the average grade of 30 students").

Step 2: Decomposition
Breaking a big, scary problem into smaller, manageable chunks. Think of it like cleaning a messy house: you don't "clean the house" all at once; you clean the kitchen, then the bedroom, then the hallway.

Step 3: Abstraction and Generalization
Abstraction means removing unnecessary details. If you are writing a program to manage bus routes, you don't need to know what color the bus seats are—you only need the route number and timing. Generalization is about making a solution that works for many cases, not just one.

Step 4: Testing and Evaluation
Checking if the solution actually works and meets the original success criteria. If it doesn't, you go back and improve it.

Analogy: Think of a recipe. The "Specification" is the name of the dish. "Decomposition" is the list of chopped ingredients. "Abstraction" is focusing on the cooking steps rather than the brand of the stove. "Evaluation" is the taste test at the end!

3. Mastering Code Questions (B.2)

Paper 2 will ask you to both read and write code. Here is how to approach these questions without panicking.

Reading and Tracing Code

You might be given a snippet of code and asked "What is the output?" or "What is the value of \( x \) after this loop?"

  • Use a Trace Table: This is a simple table where each column is a variable and each row is a step in the code. Update the values as you go.
  • Watch the loops: Pay close attention to when a loop starts and exactly when it ends (is it less than \( n \) or less than or equal to \( n \)?).

Writing Code

When you are asked to write a function or a small program:

  1. Identify the Inputs and Outputs: What data is coming in (parameters)? What needs to be returned?
  2. Don't worry about "Perfect" Syntax: While your code must be valid Java or Python, the examiners are looking for logic. If you forget a colon or a semicolon but your logic is perfect, you can still gain most (if not all) marks.
  3. Use Meaningful Variable Names: Use names like \( totalSum \) instead of \( s \). It makes your logic easier for the examiner to follow.

Quick Review: Common Logic Structures
- Selection: If/Else statements.
- Iteration: For loops (when you know how many times to repeat) and While loops (when you repeat until a condition is met).
- Arrays/Lists: Storing multiple pieces of data in one variable.

4. Object-Oriented Programming (OOP) (B.3)

OOP is a huge part of Paper 2. It's a way of organizing code into "Objects" that represent real-world things.

  • Classes: The "blueprint." (e.g., a Car class).
  • Objects: The actual thing built from the blueprint. (e.g., "My blue Toyota").
  • Attributes: Data stored inside the object (e.g., \( color \), \( speed \)).
  • Methods: Actions the object can take (e.g., \( accelerate() \), \( brake() \)).

HL Students: You will need to go much deeper into OOP concepts like Inheritance (where one class takes features from another) and Encapsulation (hiding data to keep it safe).

5. Abstract Data Types (B.4) - HL ONLY

If you are an HL student, you will face questions about how data is structured. You should be comfortable with:

  • Stacks: Like a stack of plates. LIFO (Last-In, First-Out). You "push" to add and "pop" to remove.
  • Queues: Like a line at a store. FIFO (First-In, First-Out). You "enqueue" at the back and "dequeue" from the front.
  • Linked Lists: Data items where each one points to the next one in line.
  • Trees (Binary Trees): Hierarchical data, like a family tree or a file folder system.
Mnemonic: For Stacks, think of "Stacking" books—the last one you put on top is the first one you pick up (LIFO). For Queues, think of "Queueing" for coffee—the first person in line is the first one served (FIFO).

6. Exam Strategy: How to "Solve" the Question

Many Paper 2 questions use Command Terms. Understanding them is half the battle:

  • "Trace": Follow the code step-by-step (use that trace table!).
  • "Construct": Write the code from scratch.
  • "Evaluate": Discuss the pros and cons of a specific solution. For example, "Is an Array better than a Linked List for this problem?"
  • "Explain": Don't just say what happens, say why it happens.

Common Mistakes to Avoid

  • Mixing Languages: Do not write half in Python and half in Java. Pick one and stick to it!
  • Off-by-One Errors: Forgetting that most programming languages start counting at \( 0 \), not \( 1 \).
  • Ignoring Constraints: If the question says "You must use a while loop," do not use a for loop!

Key Takeaways

Paper 2 is practical. Success comes from:

  1. Understanding the Computational Thinking Process (Specify, Decompose, Abstract, Test).
  2. Mastering your chosen language's syntax (Java or Python).
  3. Being able to trace code accurately using a table.
  4. (HL) Knowing your Abstract Data Types (Stacks, Queues, Lists, Trees) inside out.

Pro Tip: Practice writing code by hand on paper! In the exam, you won't have a computer to check for errors, so you need to get used to "compiling" the code in your head.

For more details on the types of computing systems mentioned in Paper 2 scenarios, see "Paper 1 question skills: computing systems".