Cambridge Lower Secondary CheckpointStage 8

Computational Thinking

Computing Stage 8 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.

~12 min read

1. Introduction to Computational Thinking

Computational Thinking (CT) is not about thinking like a computer, but rather a powerful problem-solving methodology that humans use. It involves breaking down complex problems into manageable parts and developing solutions that can be executed by a computer (or a human). It is a fundamental skill in computer science and many other fields. CT is built upon four key cornerstones: Decomposition, Pattern Recognition, Abstraction, and Algorithms. By mastering these four techniques, you can approach any complex problem in a structured and effective way, moving from a vague idea to a clear, step-by-step solution.

Key term

Computational Thinking: A problem-solving process that involves formulating a problem and its solution in a way that a computer can understand and execute.

Examiner insight

Examiners reward students who can not only define the four pillars of computational thinking but also apply them to a given scenario.

Fun fact

The principles of computational thinking were being used to design systems and solve problems long before modern computers were invented, for example in weaving patterns and creating census systems.

Worked example 14 marks

You are asked to organise a surprise birthday party for a friend. How could you apply the four cornerstones of computational thinking to this task?

  1. 1
    1. Decomposition: Break the problem of 'organising a party' into smaller tasks: create a guest list, send invitations, decide on a venue, plan the food and drinks, buy a cake, arrange decorations, plan activities.
  2. 2
    1. Pattern Recognition: Identify patterns. The process of inviting guests (contacting, getting RSVP) is a repeatable pattern. The process for buying supplies (food, decorations) is also a pattern: make a list, go to the shop, purchase items.
  3. 3
    1. Abstraction: Focus on the essential details. For invitations, the key information is Who, What, When, Where, and RSVP details. You can ignore details like the font colour of the email for now.
  4. 4
    1. Algorithm: Create a step-by-step plan. For example, the algorithm for invitations could be: FOR each person on guest list, SEND invitation email, WAIT for reply, UPDATE RSVP list. This creates a clear sequence of actions.

Recap

  • Computational Thinking is a method for solving complex problems.
  • It is a human-centred process, not about thinking like a machine.
  • The four cornerstones are Decomposition, Pattern Recognition, Abstraction, and Algorithms.
  • These skills are used together to develop clear, effective, and computable solutions.

Quick check

  1. List the four key components of computational thinking.2 marks

2. Decomposition: Breaking Down Problems

Decomposition is the first step in tackling a complex problem. It is the process of breaking down a large, seemingly overwhelming task into smaller, more manageable sub-problems. Each sub-problem can then be examined and solved individually. Once all the sub-problems are solved, the original complex problem is also solved. This 'divide and conquer' strategy makes problems easier to understand, manage, and assign to different people or teams.

Key term

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

Examiner insight

Examiners look for a logical and hierarchical breakdown of a problem, demonstrating that all major aspects have been considered and broken down into solvable units.

Fun fact

The 'Work Breakdown Structure' used in project management is a direct application of decomposition, used to plan everything from building a skyscraper to launching a space mission.

Worked example 15 marks

A software team needs to create a simple 'To-Do List' application. Decompose this problem into at least five smaller sub-problems.

  1. 1

    The problem 'Create a To-Do List application' can be decomposed into the following sub-problems:

  2. 2
    1. User Interface Design: Design the screen layout, including where the list will be displayed and where the buttons will go.
  3. 3
    1. Add New Task Functionality: Develop the code to allow a user to type in a new task and add it to their list.
  4. 4
    1. Display Tasks: Write the code to show all the current tasks in the main list view.
  5. 5
    1. Mark Task as Complete: Implement a way for users to check off or mark a task as done, which might involve changing its appearance (e.g., strikethrough).
  6. 6
    1. Delete Task Functionality: Create a function to permanently remove a task from the list.
  7. 7
    1. Data Persistence: Develop a way to save the tasks so they are not lost when the application is closed and reopened.

Recap

  • Decomposition involves breaking a large problem into smaller sub-problems.
  • This makes the overall problem easier to understand and manage.
  • Each sub-problem can be solved independently.
  • Solving all the sub-problems leads to the solution of the original problem.

Quick check

  1. Why is decomposition a useful first step in problem-solving?1 mark

3. Pattern Recognition: Finding Similarities

After decomposing a problem, you often find that some of the smaller sub-problems are very similar. Pattern recognition is the skill of identifying these similarities, trends, or regularities. By spotting these patterns, you can create a single, general solution that can be applied to all the similar sub-problems, rather than creating a separate, specific solution for each one. This makes the overall solution simpler, more efficient, and quicker to develop.

Key term

Pattern Recognition: The process of identifying trends, regularities, or common characteristics among different problems or within a set of data.

Common pitfall

Only looking for visual patterns. In computational thinking, patterns can be in processes, data structures, or rules, not just things that look the same.

Fun fact

Streaming services like Netflix and Spotify use sophisticated pattern recognition algorithms to analyse your viewing/listening habits and recommend new content you might like.

Worked example 14 marks

When creating a character in a video game, the user must enter a username, a character name, and a guild name. Each of these must be between 3 and 15 characters long. Describe the pattern and how it can be used to simplify the solution.

  1. 1
    1. Identify the Sub-problems: The sub-problems are: validating the username, validating the character name, and validating the guild name.
  2. 2
    1. Recognise the Pattern: The pattern is that all three validation tasks follow the same rule: check if the length of the input string is greater than or equal to 3 AND less than or equal to 15.
  3. 3
    1. Create a General Solution: Instead of writing the validation code three separate times, we can create a single, reusable function. For example, a function called `isValidLength(text)` that takes the input string as a parameter.
  4. 4
    1. Apply the Solution: This single function can then be called three times: once for the username, once for the character name, and once for the guild name. This saves time and reduces the chance of errors.

Recap

  • Pattern recognition involves finding similarities or trends in decomposed problems.
  • It helps in creating general solutions that can be reused.
  • Using patterns makes solutions more efficient and easier to manage.
  • This principle is fundamental to creating efficient code and solving problems at scale.

Quick check

  1. How does pattern recognition lead to more efficient solutions?2 marks

4. Abstraction: Focusing on What Matters

Abstraction is the process of filtering out information that is not necessary to solve the problem at hand. It involves removing detail and complexity to focus on the essential features. By creating a simplified model of the problem, we can make it easier to understand and solve without getting bogged down in irrelevant details. Abstraction is about deciding what is important and what can be ignored.

Key term

Abstraction: The process of removing or hiding unnecessary complexity to focus on the essential characteristics of a problem or system.

Examiner insight

Marks are often awarded for justifying why certain details are considered essential while others are irrelevant for a specific problem context.

Fun fact

Programming languages are a form of abstraction. They hide the complex binary instructions the computer actually uses, allowing programmers to write code using more human-readable commands.

Worked example 16 marks

You are creating a simulation of traffic flow in a city. Using abstraction, identify three essential details you would need to model and three irrelevant details you would ignore.

  1. 1
    1. Identify the Goal: The goal is to simulate traffic flow. This means we care about how vehicles move and interact.
  2. 2
    1. Identify Essential Details: To model traffic flow, we need to include: the speed of vehicles, the position of vehicles on the road, and the state of traffic lights (red, green, amber).
  3. 3
    1. Identify Irrelevant Details: To simplify the model, we can ignore details that do not significantly affect traffic flow. These include: the colour of the cars, the number of passengers in each car, and the make and model of each vehicle.

Recap

  • Abstraction simplifies complex problems by removing unnecessary detail.
  • It involves creating a model of the problem that includes only essential features.
  • Good abstraction makes problems easier to understand and solve.
  • A map is a classic example of abstraction, simplifying reality to show routes.

Quick check

  1. Explain why a car's dashboard is an example of abstraction.2 marks

5. Algorithms: Creating the Solution

An algorithm is the final piece of the puzzle. After decomposing, finding patterns, and abstracting, you design an algorithm: a precise, step-by-step set of instructions for solving the problem. For an algorithm to be valid, it must be unambiguous (each step has only one meaning), finite (it must eventually end), and executable (a computer or human can carry it out). Algorithms are commonly represented using pseudocode (a structured, English-like notation) or flowcharts (diagrams that use standard symbols).

Key term

Algorithm: A finite sequence of well-defined instructions for accomplishing a specific task or solving a problem.

Common pitfall

Writing steps that are too vague, like 'process the data'. An algorithm requires specific instructions, such as 'add the numbers' or 'sort the list in ascending order'.

Worked example 13 marks

Write an algorithm in pseudocode to calculate the average of three numbers.

  1. 1
    1. Input: Start by getting the required data.
  2. 2

    INPUT num1

  3. 3

    INPUT num2

  4. 4

    INPUT num3

  5. 5
    1. Process: Perform the calculation.
  6. 6

    total = num1 + num2 + num3

  7. 7

    average = total / 3

  8. 8
    1. Output: Display the result.
  9. 9

    OUTPUT average

Worked example 24 marks

Draw a flowchart for an algorithm that turns on a light if it is dark and the switch is on.

  1. 1
    1. Start with a 'Start' terminal symbol.
  2. 2
    1. Use a parallelogram for input: 'Is it dark?'.
  3. 3
    1. Use a diamond for the first decision: 'Is it dark?'. The 'Yes' path continues; the 'No' path goes to an 'End' terminal.
  4. 4
    1. From the 'Yes' path, use another diamond for the second decision: 'Is switch on?'. The 'Yes' path continues; the 'No' path goes to the 'End' terminal.
  5. 5
    1. From the 'Yes' path of the second decision, use a rectangle for the process: 'Turn on light'.
  6. 6
    1. All paths should eventually lead to a final 'End' terminal symbol.

Recap

  • An algorithm is a step-by-step guide to solving a problem.
  • Algorithms must be precise, unambiguous, and finite.
  • Pseudocode uses structured English to describe algorithmic steps.
  • Flowcharts use standard symbols to visually represent the flow of an algorithm.

Quick check

  1. What is the key difference between pseudocode and a flowchart?2 marks

6. Evaluation: Is the Solution Fit for Purpose?

Developing a solution is not the end of the process. Evaluation is the critical step of assessing the solution to determine if it is 'good'. A good solution is not just one that works sometimes; it must be correct, efficient, and easy to understand. Correctness means it works for all valid inputs and produces the right output. Efficiency refers to how well it uses resources like time (how fast it runs) and memory (how much space it takes). A solution must be fit for its purpose, and evaluation is how we measure that.

Key term

Evaluation: The process of assessing a computational solution to ensure it is correct, efficient, and meets the requirements of the problem.

Examiner insight

Examiners expect a nuanced evaluation. Instead of just saying a solution is 'good' or 'bad', students should justify their judgement with specific criteria like speed, memory usage, and correctness for edge cases.

Fun fact

Google's search algorithm is constantly being evaluated and updated thousands of times per year to ensure it provides the most correct and relevant results as quickly as possible.

Worked example 14 marks

A student writes an algorithm to find a user's name in a class register of 30 students. The algorithm checks each name one by one from the start. Evaluate this algorithm in terms of correctness and efficiency.

  1. 1
    1. Evaluate Correctness: The algorithm is correct. By checking every name from the beginning until a match is found (or the end is reached), it will reliably find the name if it exists and confirm its absence if it does not. It works for all valid inputs.
  2. 2
    1. Evaluate Efficiency: For a small list of 30 students, this algorithm (a linear search) is perfectly efficient. It will be almost instantaneous. The simplicity of the algorithm is a benefit here.
  3. 3
    1. Conclusion: The solution is fit for purpose. While it is not the most theoretically efficient algorithm for searching, its simplicity and the small scale of the problem make it an excellent choice. For a list of millions, it would be very inefficient, but for 30 names, it is fine.

Recap

  • Evaluation judges whether a solution is fit for its purpose.
  • Key criteria for evaluation include correctness and efficiency.
  • Correctness means the solution gives the right output for all valid inputs.
  • Efficiency measures the use of time and memory resources.
  • The 'best' solution is often a trade-off between simplicity and efficiency.

Quick check

  1. List two criteria, other than 'it works', that you would use to evaluate an algorithm.2 marks

End-of-chapter exercise

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

  1. Define 'Computational Thinking' and briefly describe each of its four cornerstones.5 marks
  2. You have been tasked with creating a mobile app for your school's library. Decompose this problem into at least four major, distinct sub-problems that a team could work on.4 marks
  3. Explain how abstraction has been used in the creation of email. In your answer, identify one essential feature that was kept and one real-world detail that was abstracted away.3 marks
  4. A program needs to check if a student is eligible for a scholarship. The rules are: the student must be in Year 12 or Year 13, and must have an attendance of 95% or higher. Draw a flowchart to represent the algorithm for checking eligibility.5 marks
  5. What is the difference between decomposition and abstraction? Use the example of 'designing a car' to illustrate your answer.4 marks
  6. Write an algorithm in pseudocode that asks the user for their year of birth, calculates their approximate age, and then outputs 'Child' if they are under 13, 'Teenager' if they are 13-19, and 'Adult' otherwise.6 marks
  7. Two programmers are developing a school registration system. When entering student data, the system must validate the date of birth, the enrollment date, and the graduation date. Explain how the principle of 'pattern recognition' could be applied here to make the programming more efficient.3 marks
  8. An algorithm designed to recommend friends on a social media platform is very slow, taking several minutes to produce a suggestion. However, its suggestions are very accurate. Evaluate this algorithm based on the criteria of efficiency and correctness.4 marks
  9. Explain why 'make breakfast' is not a valid algorithm. Re-write the task of making toast as a simple, 4-step algorithm.4 marks
  10. You are designing a simple weather app. Using the four pillars of computational thinking, provide a brief outline of how you would approach this project. For each pillar, give one specific example related to the weather app.8 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