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.
What you need to be able to do
- 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.
Rapid Recall Deck
Say the answer aloud before flipping. Mark secure knowledge quickly and spend time on the gaps.
Specify the problem before solving it
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: 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.
- 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.
Use computational thinking before coding
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.
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.
Scope and data types in Python
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
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.0825represents a decimal value using a Python floating-point number;is_open = Trueis Boolean;zone = "A"represents a char value using a one-character Python string;seats = 24is 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.
discount = 0.10 return label, available, discount
Static or dynamic?
Compare and recommend
Compare a fixed-size static structure with a dynamic structure for this task, then recommend one.
- 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.
Python Lists: 1D, 2D and dynamic operations
Trace the operations
rooms = ["Lab", "Library", "Studio"]
rooms.append("Commons")
rooms.remove("Library")
for room in rooms:
print(room)
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])
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.
def count_large(groups):
count = 0
for size in groups:
if size >= 20:
count += 1
return countPaper 2 mini-set
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.
- Use paired criteria: fixed allocation versus resizeable capacity; consequences for memory and overhead; flexibility; a recommendation linked to the unknown number of registrations.
rooms.append("Studio") rooms.remove("Lab") for room in rooms: print(room)- 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.
Finish the learning cycle
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.