Cambridge Lower Secondary CheckpointStage 7

Computational Thinking

Computing Stage 7 Chapter Notes

What this chapter covers

Computational Thinking
ShareWhatsAppPost
Computational Thinking notes

Unable to load PDF

The notes viewer could not load. Please refresh the page.

Read online free. Download a watermarked copy with a free account.

Read the notes

The full Computational Thinking notes as text: skim, search, and jump between subtopics.

~10 min read

1. Decomposition: Breaking Down Problems

Decomposition is the first step in computational thinking. It is the process of breaking down a large, complex problem into smaller, more manageable sub-problems. Each sub-problem can be focused on and solved individually, which is much less overwhelming than tackling the entire problem at once. Once all the sub-problems are solved, their solutions are combined to solve the original large problem. For example, creating a new smartphone is a huge task, but it can be decomposed into smaller problems like designing the screen, developing the operating system, creating the battery, and writing the camera software.

Key term

Decomposition: The process of breaking down a complex problem or system into smaller, more manageable parts.

Examiner insight

Examiners reward students who can clearly identify distinct and logical sub-problems of a given scenario, rather than just vaguely describing the overall task.

Common pitfall

A common mistake is to list the steps to solve the problem (which is an algorithm) instead of identifying the smaller, self-contained sub-problems that make up the whole system.

Fun fact

Large-scale car manufacturing relies heavily on decomposition. The overall problem 'build a car' is broken down into thousands of sub-problems handled by different teams and automated assembly lines, such as engine assembly, chassis construction, and electronics installation.

Worked example 14 marks

A team is developing a new social media application. Use decomposition to break this large project down into four distinct, manageable sub-problems.

  1. 1

    Sub-problem 1: User Registration and Login. This involves creating a secure system for users to create an account, sign in, and recover their password.

  2. 2

    Sub-problem 2: Profile Management. This system would allow users to create and edit their personal profile, including uploading a profile picture and writing a bio.

  3. 3

    Sub-problem 3: News Feed. This involves developing the core functionality to display posts from friends or followed accounts in a chronological or algorithmically sorted list.

  4. 4

    Sub-problem 4: Posting and Interacting. This system would handle the creation of new posts (text, images, videos) and interactions like 'liking' and 'commenting'.

Recap

  • Decomposition simplifies complex problems by breaking them into smaller parts.
  • It is the starting point for applying computational thinking.
  • Each sub-problem can be solved independently.
  • The solutions to the sub-problems are combined to solve the overall problem.

Quick check

  1. What is the main benefit of using decomposition when faced with a complex problem?1 mark
  2. Decompose the task of 'hosting a birthday party' into three sub-problems.3 marks

2. Pattern Recognition: Finding Similarities

After decomposing a problem, we often find that some of the sub-problems are very similar. Pattern recognition is the process of identifying these similarities, trends, or regularities. By spotting these patterns, we can create a single, reusable solution instead of creating a new solution for every single sub-problem. This makes the overall solution more efficient, quicker to develop, and less prone to errors. For instance, if you are coding a game and have many enemy characters that all move in the same way, you can write the movement code once and reuse it for every enemy.

Key term

Pattern Recognition: The process of identifying trends, similarities, or regularities in data or among different parts of a problem.

Examiner insight

Marks are often awarded for identifying a specific pattern and then clearly explaining how exploiting that pattern leads to a more efficient or simplified solution.

Common pitfall

Simply stating that 'there is a pattern' is not enough; students must describe the specific, repeating characteristic they have identified.

Fun fact

Weather forecasting heavily relies on pattern recognition. Meteorologists analyse vast amounts of historical weather data to find patterns that help them predict future weather conditions.

Worked example 13 marks

In a banking application, the software needs to validate a user's PIN, validate their online banking password, and validate a one-time code sent to their phone. Identify the pattern in these tasks and explain how it can be used to create an efficient solution.

  1. 1

    Step 1: Identify the pattern. The core task in all three cases is 'validation'. This involves taking a user's input and comparing it against a stored, correct value.

  2. 2

    Step 2: Describe the general solution. A general 'validation' process can be designed: (1) Receive user input. (2) Retrieve the correct, stored value. (3) Compare the input with the stored value. (4) Return a result of 'True' if they match, and 'False' if they do not.

  3. 3

    Step 3: Explain the efficiency. Instead of writing separate code for PINs, passwords, and one-time codes from scratch, a single, reusable function or module (e.g., `validateInput(userInput, correctValue)`) can be created. This function can then be called three times with the different data, saving development time and reducing the chance of errors.

Recap

  • Pattern recognition involves finding similarities or trends within a decomposed problem.
  • Identifying patterns allows for the creation of efficient, reusable solutions.
  • Reusing solutions saves time, reduces code size, and minimises errors.
  • Patterns can be found in data, processes, or the structure of problems.

Quick check

  1. How does finding a pattern help a programmer write less code?1 mark

3. Abstraction: Focusing on What Matters

Abstraction is the process of filtering out and ignoring characteristics that are not relevant to the problem we are trying to solve. It involves focusing only on the essential details that matter. This helps to reduce complexity and allows us to create a simplified model of the problem. A great example is a London Underground map. It is an abstraction of the real world; it shows the stations, the lines connecting them, and the order of stops. It abstracts away irrelevant details like the exact geographical path of the tunnels, the distance between stations, and the streets above ground, because a traveller only needs to know how to get from station A to station B.

Key term

Abstraction: The process of removing unnecessary detail from a problem to focus on the essential features required to solve it.

Examiner insight

Examiners look for the ability to identify specific details that can be ignored and to provide a clear justification for why they are irrelevant to solving the core problem.

Common pitfall

Confusing abstraction with decomposition. Abstraction is about simplifying by removing detail from one thing, while decomposition is about breaking one thing into multiple smaller things.

Fun fact

The icons on your phone are a powerful form of abstraction. A single 'mail' icon represents the entire complex system of email protocols, servers, and networks, hiding all that detail so you can just tap to read your messages.

Worked example 14 marks

You are creating a computer program to simulate a car in a racing game. Using the principle of abstraction, identify two essential details you must include and two irrelevant details you can ignore.

  1. 1

    Essential Detail 1: The car's current speed and direction. This is fundamental for moving the car around the track and determining its position.

  2. 2

    Essential Detail 2: The car's fuel level. This is a key gameplay mechanic that affects whether the car can continue racing and may require a pit stop.

  3. 3

    Irrelevant Detail 1: The car's engine temperature. While important in a real car, for most racing games this level of detail is too complex and does not add to the fun, so it is ignored.

  4. 4

    Irrelevant Detail 2: The material the seats are made from (e.g., leather, fabric). This detail is purely cosmetic and has no impact on the car's performance in the simulation, so it is abstracted away.

Recap

  • Abstraction simplifies complexity by removing unnecessary details.
  • It helps us create models of the real world to solve problems.
  • What is considered 'irrelevant detail' depends entirely on the problem being solved.
  • Variables, functions, and objects in programming are all forms of abstraction.

Quick check

  1. Explain why a variable name like 'userScore' is a form of abstraction.2 marks

4. Algorithms: Creating Step-by-Step Solutions

An algorithm is the final piece of the computational thinking puzzle. It is a finite sequence of precise, unambiguous instructions for solving a problem or performing a task. After decomposing a problem, finding patterns, and abstracting away details, you need a concrete plan to actually create the solution. This plan is the algorithm. For a computer to follow an algorithm, the instructions must be in the correct order and be so clear that there is no room for misinterpretation. Algorithms are often designed using tools like pseudocode (a structured, English-like way of writing steps) or flowcharts before being translated into a programming language.

Key term

Algorithm: A finite sequence of well-defined, step-by-step instructions for carrying out a computation or for solving a problem.

Examiner insight

Clear, logical, and unambiguous steps are key. Examiners will penalise algorithms that miss crucial steps (like initialising a total to zero) or have instructions in the wrong sequence.

Common pitfall

Writing steps that are too vague, such as 'Calculate the average'. A correct algorithmic step would be 'Sum all the numbers, count how many numbers there are, then divide the sum by the count'.

Fun fact

The recipe for a cake is a type of algorithm. It has a list of inputs (ingredients), a sequence of precise steps to follow, and a defined end product (a cake).

Worked example 15 marks

Write an algorithm in pseudocode that asks a user for their age. If they are 18 or over, it should display 'Access granted'. Otherwise, it should display 'Access denied'.

  1. 1

    Step 1: Prompt the user for input. `OUTPUT "Please enter your age:"`

  2. 2

    Step 2: Store the user's input. `INPUT userAge`

  3. 3

    Step 3: Use selection to check the condition. `IF userAge >= 18 THEN`

  4. 4

    Step 4: Define the output for the 'true' path. ` OUTPUT "Access granted"`

  5. 5

    Step 5: Define the output for the 'false' path. `ELSE`

  6. 6

    Step 6: Complete the 'false' path. ` OUTPUT "Access denied"`

  7. 7

    Step 7: End the selection structure. `ENDIF`

Worked example 24 marks

A list contains five test scores. Design an algorithm to calculate and display the total of these scores.

  1. 1

    Step 1: Initialise a variable to hold the running total. `Total = 0`

  2. 2

    Step 2: Initialise a list with the scores. `Scores = [88, 92, 75, 100, 85]`

  3. 3

    Step 3: Set up a loop to iterate through each score in the list. `FOR EACH Score IN Scores`

  4. 4

    Step 4: Add the current score to the total. ` Total = Total + Score`

  5. 5

    Step 5: End the loop. `ENDFOR`

  6. 6

    Step 6: Display the final result. `OUTPUT "The total score is: " + Total`

Recap

  • An algorithm is a step-by-step plan for solving a problem.
  • Instructions in an algorithm must be precise, ordered, and have a clear end point.
  • Algorithms are the bridge between a problem's design and its implementation in code.
  • Pseudocode and flowcharts are used to design and communicate algorithms.
  • Key algorithmic structures include sequence, selection (IF/ELSE), and iteration (loops).

Quick check

  1. What is the difference between an algorithm and a program?2 marks
  2. Why is the order of instructions in an algorithm so important?1 mark

End-of-chapter exercise

Test yourself on the whole chapter. Work through these before moving on.

  1. You are tasked with organising a school sports day. Use decomposition to list four main components that need to be planned.4 marks
  2. Write a simple algorithm, using numbered steps, to describe how to withdraw cash from an ATM.5 marks
  3. When you use a satellite navigation app on your phone, you see a simplified map. This is an abstraction. Identify two complex details about the real world that are being hidden from the user to make the map easier to understand.2 marks
  4. A program needs to draw a chessboard, which consists of 64 squares arranged in an 8x8 grid, alternating in colour. Explain how pattern recognition would be used to write this program efficiently.3 marks
  5. A vending machine dispenses a can of drink. Briefly explain how each of the four pillars of computational thinking (Decomposition, Pattern Recognition, Abstraction, Algorithm) could be applied to the problem of designing how the machine works.4 marks
  6. Write an algorithm in pseudocode that takes a temperature in Celsius as input, converts it to Fahrenheit using the formula F = (C * 9/5) + 32, and displays the result.4 marks
  7. You are designing a simplified 'Pac-Man' computer game. Use decomposition to identify three main software modules. Then, for the 'ghost movement' module, use abstraction to identify two key pieces of information you need to track for each ghost and one detail you can ignore.6 marks
  8. A list contains an unknown number of positive integers, ending with the number -1 to signify the end of the list. Write an algorithm in pseudocode to count and display how many numbers are in the list (excluding the -1).5 marks
  9. A user wants to find the smallest number in a list of 10 numbers. Describe the algorithmic process for this and write the algorithm in pseudocode.6 marks
  10. Explain the relationship between decomposition and abstraction. How do they work together to help manage the complexity of a large software project?4 marks

Go deeper

Practise and revise with member-only material for this chapter.

Free notes are just the start.

Unlock every Workbook and Chapter at a Glance, and generate your own worksheets and predicted papers.

Explore plans

Related chapters