IB Computer Science HL · Year 2 · Lesson 1

Computational Thinking & Data Structures

Reactivate computational-thinking foundations, then apply them to Paper 2 tasks involving scope, data types, static and dynamic structures, and Python Lists.

Paper 2 50 minutes B1.1.1–B1.1.3 · B2.1.1 · B2.2.1–B2.2.2
Today’s targets

What you need to be able to do

2 / 10
  • construct a problem specification using problem, constraints, goals, inputs, outputs and evaluation criteria;
  • describe abstraction, algorithmic design, decomposition and pattern recognition, then explain how computational thinking helps solve problems;
  • construct and trace Python code containing global and local variables and values corresponding to the required Boolean, char, decimal, integer and string categories;
  • compare static and dynamic data structures using allocation, resizing, speed, memory use and flexibility;
  • construct Python programs using 1D and 2D Lists, including adding, removing and traversing elements.
B1.1.1B1.1.2B1.1.3 B2.1.1B2.2.1B2.2.2
Paper 2 habitAnswer the command term in the context given. Accurate technical detail matters more than repeating syllabus wording.
Retrieve

Rapid Recall Deck

3 / 10

Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.

B1.1.1 + B1.1.2

Specify the problem before solving it

4 / 10
ScenarioA school wants a course-recommendation tool that suggests suitable courses from a student’s interests and academic history. No code has been written yet.

1 · Construct a problem specification

For this exercise, include one concise entry for each of the six Guide elements below. Keep the evaluation criterion testable.

Problem — what needs to be solved?
Constraints — what limits the solution?
Goals — what should the solution achieve?
Inputs — what data enters the system?
Outputs — what should the system produce?
Evaluation — how will success be checked?
  • Problem: students need help identifying appropriate courses from many available options.
  • Constraints: the tool can only use available student/course data and must not recommend unavailable courses.
  • Goal: recommend eligible courses that match the student’s stated interests.
  • Inputs: interests, completed courses and relevant academic data.
  • Outputs: a ranked list of eligible courses matched to the student’s stated interests.
  • Evaluation: for valid test profiles, every returned course is eligible, each recommendation matches at least one stated interest, and the tool returns the requested number of recommendations.

2 · Retrieve the four concepts

Name all four computational-thinking concepts and give the purpose of each in one short phrase.

Your response — four concept names + one accurate purpose for each.
  • Abstraction: retain essential information and ignore irrelevant detail.
  • Algorithmic design: create an ordered method for turning inputs into outputs.
  • Decomposition: break the overall problem into smaller manageable components.
  • Pattern recognition: identify similarities or recurring features that can guide a solution.
B1.1.3 · Explain

Use computational thinking before coding

5 / 10

Explain aloud first

A team has a computing problem but has not written any code yet. Explain two ways computational thinking can help the team make progress. Use two of the four concepts from the previous page.

Choose two concepts and use them accurately.
For each one, state what the team would actually do.
Link the action to the benefit for solving the problem.
Make the key point that useful computational thinking can happen before programming.

The team could use decomposition to split the problem into smaller parts, such as input, processing and output, making the overall task easier to manage. It could also use abstraction to decide which details are essential to the solution and which can be ignored, reducing unnecessary complexity. Neither step requires code to have been written; both help structure the problem before implementation begins.

Other valid choices: pattern recognition could identify recurring features or similar cases, while algorithmic design could organize the eventual solution into a clear ordered procedure.

Why this is an “Explain” responseA definition alone is not enough. The response links a computational-thinking technique to an action and then to how that action helps solve the problem.
B2.1.1 · Construct + trace

Scope and data types in Python

6 / 10
school_name = "North Campus"
tax_rate = 0.0825
is_open = True

def make_label(room, seats):
    zone = "A"
    available = seats > 0
    label = zone + "-" + room
    return label, available

result = make_label("Lab", 24)
print(school_name, result)

Trace before running

Identify: the global variables; the local variables during the function call; the type/representation of school_name, tax_rate, is_open, zone and seats; and the final printed output.
  • Globals: school_name, tax_rate, is_open, result.
  • Locals during the call: room, seats, zone, available, label.
  • Values/types: school_name = "North Campus" is a string; tax_rate = 0.0825 represents a decimal value using a Python floating-point number; is_open = True is Boolean; zone = "A" represents a char value using a one-character Python string; seats = 24 is an integer.
  • Output: North Campus ('A-Lab', True)

Python mapping used in this course: Boolean → bool; char → one-character str; decimal → floating-point value; integer → int; string → str.

Quick construct

Modify make_label() so it creates a local decimal value discount = 0.10 and returns it with label and available.

Only two changes are needed: create the local value, then include it in the return value.
discount = 0.10
return label, available, discount
B2.2.1 · Compare

Static or dynamic?

7 / 10
DecisionA sensor records one reading every minute. The run may stop early or be extended, so the number of readings is not known when the program starts.

Compare and recommend

Compare a fixed-size static structure with a dynamic structure for this task, then recommend one.

Allocation / resizing
Speed / resizing overhead
Memory use
Flexibility
Recommendation — link it to the unknown number of readings.
  • A static structure allocates a fixed capacity, whereas a dynamic structure can change size as readings are added.
  • A static structure avoids resizing overhead, but unused capacity can waste memory and a fixed capacity can become insufficient.
  • A dynamic structure is more flexible and can grow with the data, although resizing/allocation can add overhead.
  • Because the final number of readings is unknown, the dynamic structure is the stronger choice unless predictable fixed memory allocation is the overriding requirement.

Repair cue: static = fixed capacity; dynamic = resizeable capacity. Then compare the consequences using the same criteria.

Response structureOrganize the answer by common criteria rather than writing two disconnected descriptions.
B2.2.2 · Construct + trace

Python Lists: 1D, 2D and dynamic operations

8 / 10

Trace the operations

rooms = ["Lab", "Library", "Studio"]
rooms.append("Commons")
rooms.remove("Library")

for room in rooms:
    print(room)
State: the final value of rooms and the order of the printed output.

Final List: ["Lab", "Studio", "Commons"]

Output: Lab, then Studio, then Commons on separate lines.

Trace a 2D List

seats = [
    [24, 30],
    [18, 20]
]

print(seats[1][0])
First trace: predict the printed value and explain what the two indices select. Then construct: write Python statements that change that same element from 18 to 22 and print the updated second row.

Trace: 18 — index 1 selects the second row [18, 20], then index 0 selects its first value.

seats[1][0] = 22
print(seats[1])

The updated row is [22, 20].

Construct challenge

Write count_large(groups) so it returns how many values in a 1D List are at least 20.

Your function must: accept the List, traverse every value, count values ≥ 20, and return the final integer count.
def count_large(groups):
    count = 0
    for size in groups:
        if size >= 20:
            count += 1
    return count
Exam lens

Paper 2 mini-set

9 / 10
Teacher-created exam-style practiceAnswer without notes first. The prompts use the official command terms and scope from today’s syllabus points.

1. A school event system does not know in advance how many students will register. Compare a static and a dynamic data structure for storing the registrations, then recommend one.

2. Given rooms = ["Lab", "Library"], construct Python statements that add "Studio", remove "Lab", then traverse the List and print every remaining item.

3. A team is planning a software system but has not written code. Explain how decomposition and abstraction could help the team make progress.

  1. Use paired criteria: fixed allocation versus resizeable capacity; consequences for memory and overhead; flexibility; a recommendation linked to the unknown number of registrations.
  2. rooms.append("Studio")
    rooms.remove("Lab")
    for room in rooms:
        print(room)
  3. Decomposition should split the system into manageable parts; abstraction should identify essential information and ignore irrelevant detail. For each technique, connect the action to why it makes the problem easier to solve before programming begins.
Homework

Finish the learning cycle

10 / 10

IA — main task

Review the current problem specification. Check that the problem and constraints are clear, and that success/evaluation criteria are specific enough to test rather than subjective.

Syllabus — 10–15 min

Repeat only the flashcards marked “Review again”, then redo the Paper 2 mini-set without revealing the marking points.