Computational Thinking and Algorithms
Computational thinking is a problem‑solving mindset that equips you to break down complex challenges into manageable pieces, recognize patterns, and design step‑by‑step solutions called…

In a bottom‑up approach, what term describes the process of combining modules?
When using decomposition, which of the following is a potential disadvantage?
Which pillar of computational thinking focuses on removing unnecessary details?
A flowchart becomes difficult to maintain when:
Which of the following statements about pseudocode is true?
In a trace table, each column typically represents:
Which logical operator returns true only when both conditions are true?
When validating a password, which condition must be met according to the activity description?
Which relational operator means "greater than or equal to"?
What is the primary purpose of using a modularisation approach in object‑oriented programming?
Which of the following is a correct description of pattern recognition in coding?
When creating a flowchart, which symbol is used to represent a decision point?
In the described delivery‑cost algorithm, which construct would you use to choose the correct cost band?
Which advantage of using code from a library is mentioned in the text?
What is a key disadvantage of using a pre‑written library when the required functionality is very specific?
Which step is NOT part of the four‑step decomposition process described?
When applying abstraction to the London Underground map, which information is intentionally omitted?
Which logical operator would you use to ensure a password contains both a number and a special character?
In the pseudocode example that multiplies a user input by numbers 1‑7, what is the output after the loop completes?
Which of the following best explains why an algorithm must be language independent?
Introduction to Computational Thinking and Algorithms
Computational thinking is a problem‑solving mindset that equips you to break down complex challenges into manageable pieces, recognize patterns, and design step‑by‑step solutions called algorithms. In this course we will explore the core pillars of computational thinking, the difference between top‑down and bottom‑up design, and essential tools such as flowcharts, pseudocode, trace tables, and logical operators.
1. The Top‑Down Approach: Decomposition from the Big Idea
The top‑down approach begins with an abstract view of the problem and repeatedly decomposes it into smaller sub‑problems until each piece is simple enough to solve directly.
Key Characteristics
- Hierarchical decomposition: Start with a high‑level description, then split it into increasingly detailed modules.
- Focus on the "big picture": You keep the overall goal in mind while you work on each sub‑task.
- Iterative refinement: Each decomposition step may be revisited as new insights emerge.
How to Remember
- Mnemonic: “Big Idea → Small Pieces”.
- Visual metaphor: peeling an onion layer by layer – you start with the whole onion (the abstract problem) and peel away layers (sub‑problems) until you reach the core.
When to Use Top‑Down
Top‑down is ideal when you have a clear overall objective but need to figure out the steps to achieve it, especially in large projects where coordination among many developers is required.
2. The Bottom‑Up Approach: Building from Modules
In contrast, the bottom‑up approach starts with concrete, low‑level modules that are already implemented. These modules are then integrated to form larger components and eventually the complete system.
Integration Explained
Integration is the process of combining independent modules into a cohesive whole. It often involves defining clear interfaces, handling data exchange, and ensuring that the combined behavior matches the original specification.
Advantages of Bottom‑Up
- Modules can be developed and tested in isolation, reducing early‑stage bugs.
- Reusability: well‑crafted modules can be reused across different projects.
- Parallel development: multiple teams can work on separate modules simultaneously.
Potential Pitfalls
While bottom‑up encourages modularity, it can lead to integration challenges if the modules were not designed with the overall architecture in mind.
3. Decomposition: Benefits and Disadvantages
Decomposition—splitting a problem into sub‑problems—is a cornerstone of computational thinking. It enables parallel work, simplifies testing, and clarifies responsibilities.
Potential Disadvantage
One key risk is that sub‑problem modules may not combine to solve the initial problem. If the decomposition is too granular or the interfaces are poorly defined, the assembled system may fail to meet the original requirements.
Mitigation Strategies
- Maintain a clear mapping between each sub‑module and the overall goal.
- Define consistent interfaces and data contracts early in the design phase.
- Regularly review integration points during development.
4. Pillars of Computational Thinking
Four fundamental pillars guide the computational thinking process:
- Decomposition – breaking a problem into smaller, more manageable parts.
- Pattern Recognition – identifying similarities or trends among data.
- Abstraction – removing unnecessary details to focus on the core concepts.
- Algorithm Design – creating step‑by‑step instructions to solve the problem.
Abstraction Explained
Abstraction is the pillar that focuses on removing unnecessary details. By ignoring irrelevant information, you can concentrate on the essential structure of a problem, making it easier to devise a solution.
5. Visual Tools: Flowcharts and Pseudocode
5.1 Flowcharts
Flowcharts use standardized symbols to represent the logical flow of a program. They are excellent for communicating ideas to non‑technical stakeholders.
When Flowcharts Become Hard to Maintain
A flowchart becomes difficult to maintain when it represents a large, complicated program. As the number of decision symbols and branches grows, the diagram can become cluttered, making it hard to trace the overall logic.
5.2 Pseudocode
Pseudocode is an informal, high‑level description of an algorithm that resembles programming language syntax but is not bound by strict rules. Its main advantage is that it can be quickly modified and later translated into actual code.
- It does not run directly on a computer.
- It focuses on clarity rather than exact syntax.
- It serves as a bridge between human reasoning and executable code.
6. Analyzing Algorithms with Trace Tables
A trace table records the values of variables at each step of an algorithm, helping you verify correctness and understand execution flow.
Column Meaning
In a trace table, each column typically represents a variable used in the algorithm. Rows correspond to successive steps or iterations, allowing you to track how each variable changes over time.
Example
| Step | i | sum | |------|---|-----| | 1 | 1 | 0 | | 2 | 2 | 1 | | 3 | 3 | 3 |
This simple table shows how the variable i and the accumulator sum evolve during a loop.
7. Logical Operators in Algorithms
Logical operators combine Boolean expressions to control program flow. Understanding their truth tables is essential for writing correct conditional statements.
AND Operator
The AND operator returns true only when both conditions are true. Its truth table is:
- True AND True → True
- True AND False → False
- False AND True → False
- False AND False → False
Other Operators (Brief Overview)
- OR – true if at least one condition is true.
- XOR – true only when exactly one condition is true.
- NOT – inverts the truth value.
8. Putting It All Together: A Mini‑Project
To reinforce the concepts, let’s design a simple algorithm that calculates the factorial of a number using a top‑down approach, then implement it with pseudocode, visualize it with a flowchart, and verify it using a trace table.
Step 1 – Top‑Down Decomposition
- Problem: Compute n! (factorial of n).
- Decompose:
- Validate input (n ≥ 0).
- Initialize result = 1.
- Loop from 1 to n, multiplying result each iteration.
- Return result.
Step 2 – Pseudocode
FUNCTION factorial(n)
IF n < 0 THEN
RETURN "Invalid input"
END IF
result ← 1
FOR i ← 1 TO n DO
result ← result * i
END FOR
RETURN result
END FUNCTION
Step 3 – Flowchart (Description)
Start → Input n → Decision (n < 0?) → Yes: Output "Invalid" → End; No: Initialize result → Loop (i = 1 to n) → Multiply → Increment i → Loop back → After loop, output result → End.
Step 4 – Trace Table
| i | result | |---|--------| | 1 | 1 | | 2 | 2 | | 3 | 6 | | 4 | 24 |
For n = 4, the table shows how the variable result evolves, confirming the algorithm works as intended.
Conclusion
Computational thinking equips you with a systematic toolkit: decompose problems, recognize patterns, abstract away noise, and design algorithms. Whether you adopt a top‑down or bottom‑up strategy, the key is to maintain clear interfaces, keep the big picture in view, and verify each step with tools like flowcharts, pseudocode, trace tables, and logical operators. Mastering these concepts will enable you to tackle increasingly complex programming challenges with confidence.
