Skip to content

9618 · 9.1

Computational Thinking Skills — practice questions

Practice and worked examples for 9618 Computational Thinking Skills. Short previews only — attempt the full question in MarkScheme against the official scheme.

Worked example 1

A teacher needs a program to calculate the average test score for a class of 30 students. The scores are integers out of 100. Describe how computational thinking could be used to solve this problem.

Show solution outline

Here is a breakdown of the solution using computational thinking skills:

  1. Decomposition: The problem can be broken down into smaller parts:
    • Get the score for each of the 30 students.
    • Add all the scores together to get a total.
    • Divide the total by the number of students (30) to get the average.
    • Display the final average score.
  2. Pattern Recognition: The process of 'getting a score and adding it to a running total' is repeated for every student. This pattern is identical for all 30 students.
    • This suggests that a loop (iteration) would be an efficient way to implement this part of the solution.
  3. Abstraction: We can abstract away unnecessary details. We don't need to know the students' names or the specific date of the test. The essential information is:
    • A list or sequence of 30 integer scores.
    • A variable to hold the running total (e.g., TotalScore).
    • A constant for the number of students (e.g., ClassSize=30ClassSize = 30).
    • A variable to hold the final result (e.g., AverageScore).
  4. Algorithm Design (in Pseudocode):
    DECLARE TotalScore : INTEGER
    DECLARE Counter : INTEGER
    DECLARE StudentScore : INTEGER
    DECLARE AverageScore : REAL
    
    TotalScore <- 0
    FOR Counter <- 1 TO 30
        OUTPUT "Enter score for student ", Counter
        INPUT StudentScore
        TotalScore <- TotalScore + StudentScore
    NEXT Counter
    
    AverageScore <- TotalScore / 30
    OUTPUT "The average score is: ", AverageScore
    

Worked example 2

A program needs to find the highest temperature and the day it occurred from a week's worth of daily temperature readings. The readings are: Mon 22°C, Tue 25°C, Wed 24°C, Thu 28°C, Fri 27°C, Sat 23°C, Sun 26°C. Apply computational thinking to find the solution.

Show solution outline

Let's apply the four stages:

  1. Decomposition: The problem can be split into:
    • Store the seven daily temperatures and their corresponding days.
    • Iterate through the stored data.
    • Compare each day's temperature with the highest temperature found so far.
    • If a new highest temperature is found, update both the highest temperature and the corresponding day.
    • After checking all days, output the stored highest temperature and its day.
  2. Pattern Recognition: The core process is 'compare the current day's temperature to the running maximum'. This is repeated for each day of the week. This pattern indicates a loop is needed to go through the data.
  3. Abstraction: We can represent the data in a simplified way, for example, using two parallel arrays or a 2D array. We don't need to know why the temperature was a certain value, just what the value is.
    • Essential variables: HighestTemp, DayOfHighestTemp, an array for temperatures Temps=[22,25,24,28,27,23,26]Temps = [22, 25, 24, 28, 27, 23, 26], and an array for days Days=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"]Days = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"].
  4. Algorithm Design (in Pseudocode):
    DECLARE Temps : ARRAY[0:6] OF INTEGER
    DECLARE Days : ARRAY[0:6] OF STRING
    DECLARE HighestTemp : INTEGER
    DECLARE DayOfHighestTemp : STRING
    DECLARE Counter : INTEGER
    
    // Initialise data (in a real exam, this might be read from a file or input)
    Temps <- [22, 25, 24, 28, 27, 23, 26]
    Days <- ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
    
    // Assume the first day is the highest to start
    HighestTemp <- Temps[0]
    DayOfHighestTemp <- Days[0]
    
    // Loop from the second day onwards
    FOR Counter <- 1 TO 6
        IF Temps[Counter] > HighestTemp THEN
            HighestTemp <- Temps[Counter]
            DayOfHighestTemp <- Days[Counter]
        ENDIF
    NEXT Counter
    
    OUTPUT "The highest temperature was ", HighestTemp, " on ", DayOfHighestTemp