7.1 - Computational Thinking
What is computational thinking?
Computational thinking involves a set of problem-solving skills used to identify the most effective way to tackle complex challenges. It breaks down problems into manageable parts, focuses on essential details, and develops logical steps to reach solutions. This approach is not limited to computing; it applies to everyday situations and is essential in computer science for creating efficient programs.
Key techniques in computational thinking
There are three main techniques that form the foundation of computational thinking: decomposition, abstraction, and algorithmic thinking. These work together to simplify problems and guide you towards effective solutions.
Decomposition
Decomposition means dividing a complex problem into smaller, more manageable sub-problems. Each sub-problem can then be addressed individually, making the overall task less overwhelming.
Benefits of decomposition:
- This technique helps by allowing you to focus on one aspect at a time.
- For example, if planning a large event, you might break it down into tasks like booking a venue, organising food, and inviting guests.
Abstraction
Abstraction involves identifying the most important information from a problem while ignoring irrelevant details. This focuses your attention on what truly matters to solve the issue.
Benefits of abstraction:
- It simplifies the problem by removing unnecessary specifics.
- For instance, when following a recipe, you might ignore the brand of ingredients and concentrate on quantities and steps.
Algorithmic thinking
Algorithmic thinking is about creating a logical, step-by-step process to move from the problem to the solution. These steps form an algorithm, which is a reusable set of instructions that can be adapted for similar problems.
Benefits of algorithmic thinking:
- Algorithms ensure solutions are systematic and repeatable.
- An example might be a recipe's instructions, which can be followed again with slight changes for different dishes.
Applying computational thinking in real life
Computational thinking is used in everyday decisions without us always realising it. It helps organise thoughts and make choices efficiently. Consider the scenario of selecting a film to watch at the cinema with your family.
Using decomposition and abstraction for film selection
Decomposition breaks the decision into smaller questions, while abstraction helps ignore unimportant details and focus on key factors.
Using algorithmic thinking for film selection
Algorithmic thinking creates a logical sequence to reach a decision:
- List all films currently showing at the cinema.
- Remove any films that have age restrictions unsuitable for the family or those with low ratings.
- Have each family member vote for their preferred option from the remaining list.
- Select the film that receives the highest number of votes.
This process can be reused for future cinema trips, though you would need to gather new information each time, such as updated film listings and times.
Computational thinking in computer science
In computer science, these techniques help programmers convert complex tasks into problems that computers can solve. They are particularly useful for designing efficient code. Let's explore this through the example of sorting a list of product names into alphabetical order.
Decomposition in sorting a list
Sub-problems in sorting:
- Defining what "alphabetical order" means, including how to handle entries with numbers or punctuation alongside letters.
- Figuring out how to compare entries, which could be broken down further into comparing adjacent items, then larger subsets of items, and so on.
This approach makes the overall problem easier to manage by solving each part separately.
Abstraction in sorting a list
Essential details to focus on:
- The meaning or content of the product names is irrelevant; what matters is the sequence of characters in each name.
- For example, whether the name is "Apple" or "Zebra" does not affect the sorting method – only the order of letters like 'A' before 'Z' is important.
This keeps the solution general and applicable to any list of names.
Algorithmic thinking in sorting a list
Step-by-step sorting process:
- Start by taking any two adjacent entries and comparing them to place them in the correct order.
- Then, take the next entry in the list and compare it with the already sorted adjacent entries, inserting it into its correct position.
- Repeat this process for all remaining entries, always integrating the current unsorted entry into the growing sorted sequence.
This method creates a reusable algorithm, such as an insertion sort, which can be implemented in code and adapted for other sorting tasks.