Learn in your language
Skip to content
A Level · Cambridge (CIE) · 9618

9 Algorithm design and problem-solving

Decompose a problem, abstract irrelevant detail and express a verifiable algorithm with precise logic.

Section 9 · Algorithm design and problem-solving

Cambridge International AS & A Level Computer Science 9618 · 2027–2029 · Version 2 · 9

Mapped to Cambridge International AS & A Level Computer Science 9618, 2027–2029 Version 2. These original lessons and self-checks are independent study support; they are not Cambridge papers, official marks or grades. The course does not yet provide a timed four-paper simulation or a locked-down Paper 4 programming environment.

Before you begin

  • Use the 2027–2029 syllabus for your exam year. AS candidates study Sections 1–12; A Level candidates study Sections 1–20. Paper 4 uses a programming language chosen from Python, Java or Visual Basic in console mode.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

Which task is an example of abstraction?

What you will learn

  • Explain the key representations, structures or processes in this syllabus section
  • Apply the method to a new computer-science example
  • Justify a design choice and check its limits

Computational thinking turns a problem into manageable steps

Decomposition separates a complex task into smaller parts. Abstraction keeps details relevant to the problem and hides irrelevant complexity. Pattern recognition finds similarities that permit reuse.

A specification states inputs, outputs, constraints and success conditions. Stepwise refinement moves from a high-level solution toward enough detail to implement. A solution should be checked against the original requirements.

Algorithms need clear control and data flow

An algorithm can be expressed as pseudocode or a flowchart. Sequence executes steps in order; selection chooses a branch; iteration repeats steps. A trace table records variable values and conditions as the algorithm runs.

Boolean expressions combine comparisons with NOT, AND and OR. Parentheses and evaluation order matter. A test should cover normal, boundary and invalid inputs, based on the specification.

Pause and explain

Why use a trace table?

Put the idea to work

Worked example

A program must report the highest of three non-equal scores. Name useful inputs, output and one decomposition step.

Show the worked solution
  1. Inputs are the three scores.
  2. The output is the maximum score.
  3. A subtask can compare the first two, keep the larger, then compare that value with the third.

Answer Read three scores; update a current maximum twice; output the maximum.

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

An online shop must reject an order if stock is insufficient, otherwise reduce stock and confirm the order. State the decision and the two branches.

Give me a hint

Identify the comparison that separates the outcomes.

Compare my reasoning
  1. Compare requested quantity with available stock.
  2. If requested quantity exceeds stock, report unavailable and make no stock reduction.
  3. Otherwise subtract quantity and confirm the order.

IF quantity > stock, reject; ELSE reduce stock by quantity and confirm.

Look for these in your work

  • Condition stated
  • Reject branch protects stock
  • Success branch updates stock
2 · Independent

Trace total ← 2, then repeat three times: total ← total × 2. Give the value after each iteration.

Give me a hint

Update using the current value at the start of each iteration.

Compare my reasoning
  1. Initial value is 2.
  2. After iteration 1 it is 4; after 2 it is 8.
  3. After iteration 3 it is 16.

4, 8, 16.

Look for these in your work

  • Initial value respected
  • Three iterations
  • Updated value used
3 · Transfer

A temperature input must be from −20 through 50 inclusive. Give one normal, one boundary and one invalid test, with expected handling.

Give me a hint

Choose a middle value, a limit value and a value beyond the permitted range.

Compare my reasoning
  1. Normal: 18 should be accepted.
  2. Boundary: 50 should be accepted because the limit is inclusive.
  3. Invalid: 51 should be rejected or reprompted.

18 accepted; 50 accepted; 51 rejected or reprompted.

Look for these in your work

  • Three test classes
  • Inclusive boundary applied
  • Invalid outcome described

Common mistakes

  • Starting to code before clarifying inputs and expected outputs.
  • Using an abstraction that removes a condition required by the problem.
  • Tracing an assignment as though it were an algebraic equation.
Recall without your notes

What can you explain now?

What does decomposition do?

Compare with the explanation

Breaks a complex problem into smaller parts

Smaller subtasks can be designed and checked separately.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

How do decomposition, abstraction, stepwise refinement and trace tables help turn a problem into a checkable algorithm?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science

Course scope and assessment

This pathway maps the 2026 Version 2 and 2027–2029 Version 2 syllabuses, which Cambridge says have no significant changes affecting teaching. It has original teaching and guided, independent and transfer practice for all 20 syllabus sections, with topic links to the official section headings. It is mapped teaching, not proof of exam readiness or an official Cambridge grade. Paper 4 requires complete programs and testing evidence in a programming environment; the current course offers explained code and algorithm practice but does not yet provide a locked-down timed programming-paper environment, full four-paper mocks or human subject-teacher review.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.