Ch 1 · 7 Algorithm Design: Development Life Cycle and Design Methods · O Level Computer Science 2210
Topic 1 of 4 in Algorithm Design and Problem-Solving — O Level Computer Science 2210 — 69 lessons.
Introduction
Before writing any code, programmers work out exactly what the program must do and how. This lesson covers the stages every program goes through and the three ways to design a solution: structure diagrams, flowcharts and pseudocode. (Syllabus topic 7, outcomes 1–3.)
Key ideas — The program development life cycle
🧑🏫 Teacher's explanation
Building a complex software system is exactly like building a skyscraper. You wouldn't just show up with a pile of bricks and start stacking them; you need a blueprint, a team of specialists, and a way to check if the floors are level as you go.
📖 Definitions
🔍 Worked example — Easy
A student is tasked with creating a program to manage a school library. Identify the 'Analysis' tasks required for this project.
🔍 Worked example — Standard
During the 'Design' stage, a programmer uses a flowchart to represent the logic of a temperature sensor. What is the primary purpose of this design tool?
🔍 Worked example — Exam-style
A programmer is in the 'Coding' stage. They write a function to calculate tax, then immediately run it with a sample value to ensure it returns the correct result before moving to the next function. Name this specific testing approach.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
(a) Identify the stage of the program development life cycle where the developers determine the specific requirements of the food delivery service, such as the types of food, payment methods, and delivery zones. [1] (b) The developers decide to break the application into three sub-systems: 'Customer Interface', 'Restaurant Interface', and 'Driver Interface'. Name the technique used here. [1] (c) Explain why it is beneficial to perform iterative testing during the coding stage rather than waiting until the entire application is finished. [2] [4 marks]
Key ideas — Sub-systems and decomposition
Every computer system is made up of sub-systems, which are made up of further sub-systems. For example, a school system contains an attendance sub-system and a timetable sub-system, each of which has smaller parts.
🧑🏫 Teacher's explanation
Imagine you are tasked with building a massive LEGO castle. If you try to build the whole thing at once, it is overwhelming and confusing. Instead, you break it down into smaller sections: the gatehouse, the main towers, and the courtyard. Each of these sections is a 'sub-system'. Once you have the sections, you break them down further into individual bricks and walls. This is exactly how we approach complex computer programs.
📖 Definitions
🔍 Worked example — Easy
Decompose a 'Library Management System' into its primary sub-systems and identify the inputs and outputs for the 'Book Search' sub-system.
🔍 Worked example — Standard
A system calculates the total cost of a shopping basket. Decompose this into Inputs, Processes, Outputs, and Storage.
🔍 Worked example — Exam-style
An algorithm takes a list of 10 integers, finds the average, and stores it. Decompose this into the four required components.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
(a) Decompose the payroll system into three distinct sub-systems. [3] (b) For the 'Salary Calculation' sub-system, identify one input, one process, and one output. [3] [6 marks]
Key ideas — Structure diagrams
A structure diagram shows the decomposition of a system as a hierarchy: the whole problem at the top, broken into sub-problems below, and each of those into smaller tasks.
🧑🏫 Teacher's explanation
Imagine you are tasked with organizing a massive music festival. If you try to plan every single detail—from the stage lighting to the food vendor's inventory—all at once, you will be overwhelmed. Instead, you break the festival down into 'sub-systems': Ticketing, Entertainment, and Catering. Then, you break 'Ticketing' down into 'Online Sales' and 'Gate Entry'. This process of breaking a complex problem into smaller, manageable parts is called decomposition.
📖 Definitions
🔍 Worked example — Easy
Decompose a 'Library Management System' into three main sub-systems.
🔍 Worked example — Standard
A 'Smart Home Temperature Controller' has two main sub-systems: 'Sensor Module' and 'Control Module'. Decompose the 'Sensor Module' into two further sub-systems.
🔍 Worked example — Exam-style
A system for an ATM (Automated Teller Machine) is decomposed into: 1. User Interface, 2. Transaction Processing, and 3. Hardware Interface. Decompose 'Transaction Processing' into three specific sub-tasks.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
(a) Identify the main system. (b) Decompose the car wash system into three main sub-systems. (c) Decompose one of your sub-systems from part (b) into two further sub-sub-systems. [4 marks] [4 marks]
Key ideas — Flowcharts
A flowchart shows the steps of an algorithm using standard symbols connected by flow lines (arrows):
🧑🏫 Teacher's explanation
Imagine you are following a recipe to bake a cake. Before you start mixing ingredients, you need a plan. A flowchart is that plan. It is a visual map that shows every step of a process from start to finish. Instead of reading a long paragraph of instructions, you follow arrows that guide you through decisions (like 'Is the oven hot?') and actions (like 'Add sugar').
📖 Definitions
🔍 Worked example — Easy
Draw/Describe a flowchart for an algorithm that takes a temperature input and outputs 'Hot' if it is above 30^°C, otherwise outputs 'Cold'.
🔍 Worked example — Standard
A flowchart calculates the average of two numbers, x and y. Trace the logic: Input x=10, y=20. What is the final output?
🔍 Worked example — Exam-style
An algorithm uses a loop to count from 1 to 5. The flowchart shows: START arrow Set Count arrow 1 arrow Decision: Count ≤ 5? arrow (If Yes) Process: Count arrow Count + 1 arrow Loop back to Decision arrow (If No) Output Count arrow STOP. What is the final output?
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
Identify the error in this logic: The programmer used a decision symbol 'Score > 50?' instead of 'Score >= 50?'. Explain the consequence of this error. [2 marks]
Key ideas — Pseudocode
Pseudocode describes an algorithm in structured, English-like statements that are not tied to any one programming language. In Cambridge exams it follows a fixed format, for example:
🧑🏫 Teacher's explanation
Imagine you are writing a recipe for someone who has never cooked before. If you write "cook the pasta until it looks good," they might serve it crunchy or mushy. If you write "boil the pasta for 8 minutes," they know exactly what to do. Pseudocode is that precise recipe for a computer.
📖 Definitions
🔍 Worked example — Easy
Write pseudocode to input a temperature and output 'Hot' if it is above 30^°C, otherwise output 'Cold'.
🔍 Worked example — Standard
Write pseudocode to calculate the average of three numbers: a, b, and c.
🔍 Worked example — Exam-style
An algorithm uses a loop to count how many students scored 50 or more in a class of 10 students. Write the pseudocode.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
Key ideas — Explaining the purpose of an algorithm
Questions may give you an algorithm and ask its purpose. State the purpose in one sentence, then describe the processes.
🧑🏫 Teacher's explanation
Imagine you are a chef following a recipe. The recipe isn't the meal itself; it is the set of instructions that tells you how to turn raw ingredients into a finished dish. In computer science, an algorithm is that recipe. It is a step-by-step set of instructions to solve a specific problem.
📖 Definitions
🔍 Worked example — Easy
Explain the purpose and processes of the following algorithm:
🔍 Worked example — Standard
Explain the purpose and processes of the following algorithm:
🔍 Worked example — Exam-style
An algorithm is provided below. State its purpose and describe its processes.
⚠️ Common errors
🧠 Quick check 1
🧠 Quick check 2
🎯 Exam question
PassCount arrow 0 FOR i arrow 1 TO 20 INPUT Mark IF Mark ≥ 50 THEN PassCount arrow PassCount + 1 ENDIF NEXT i OUTPUT PassCount
Worked example
Decompose a program that works out the total cost of items in a shopping basket, including a 10% discount if the total is over 5000 rupees.
🔍 Worked example — Easy
Decompose a system that calculates the average of 5 test scores.
🔍 Worked example — Standard
Decompose a program that calculates the area of a circle given its radius r.
🔍 Worked example — Exam-style
Decompose a program that manages a library book lending system. The system must track books, check if a book is available, and record the due date.
⚠️ Common errors
Common mistakes
Practice
Answers: (1) Analysis: identify requirements / abstraction / decomposition; design: structure diagrams, flowcharts, pseudocode; coding: write code with iterative testing; testing: test with test data. (2) Removing unnecessary details from a problem and keeping only the important ones. (3) (a) diamond; (b) parallelogram; (c) terminator (rounded rectangle). (4) Input: temperature in °C; process: F = C × 9 / 5 + 32; output: temperature in °F; storage: the formula constants (or none needed).