Year 10 · Computer Science · Spring 2

Algorithm design and problem solving · Lesson 2 of 5

Flowcharts and Cambridge pseudocode

Practical7.2 Systems, decomposition and design tools7.3 The purpose of an algorithm

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

You will learn to

  • Identify the standard flowchart symbols and what each one is for.
  • Read and write simple Cambridge pseudocode, using ← for assignment.
  • Convert an algorithm from a flowchart to pseudocode, and back.
  • State the purpose of a given algorithm in one clear sentence.

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Success criteria

You have got it when you can say:

  • I can draw and name each flowchart symbol.
  • I can turn a short flowchart into correct pseudocode.
  • I can say what an algorithm does after reading it once.

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Retrieval starter

Questions from before. Write your answers, then show them.

  1. Last lesson

    In a trace table you write a new row…

    A Each time a value changesB Only for OUTPUTC Only at the end

    A. Each time a value changes

  2. Last unit

    The ALU does…

    A Storing filesB Arithmetic and logicC Fetching instructions

    B. Arithmetic and logic

  3. Earlier this year

    A truth table for 3 inputs has…

    A 3 rowsB 6 rowsC 8 rows

    C. 8 rows

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Key words (1 of 2)

Algorithm
A precise, ordered set of steps that solves a problem.
Program development life cycle
The four stages of making a program: analysis, design, coding and testing.
Decomposition
Breaking a problem into smaller parts that are easier to solve.
Sub-system
A smaller part of a system that does one job.

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Key words (2 of 2)

Structure diagram
A top-down diagram that shows how a system is split into sub-systems.
Flowchart
A diagram of an algorithm using standard shapes joined by flow lines.
Pseudocode
A structured, code-like way of writing an algorithm that is not tied to one language.
Check digit
An extra digit calculated from the other digits, used to catch typing errors.

7.2 Systems, decomposition and design tools · The explanation · step 1 of 6 · part 1 of 3

Sub-systems, and inputs, processes, outputs and storage

A system is a set of parts that work together to do a job. Each part is a sub-system. A sub-system can be split again until each part is small enough to code easily.

Example: a supermarket self-checkout is a system. Scanning, weighing, payment and printing the receipt are its sub-systems.

Every problem can also be decomposed into four parts.

Inputs: the data going in. Processes: what is done to the data. Outputs: the results that come out. Storage: data that must be kept for later.

7.2 Systems, decomposition and design tools · The explanation · step 1 of 6 · part 2 of 3

Sub-systems, and inputs, processes, outputs and storage (continued)

PartSupermarket self-checkout
InputsBarcode of each item, weight, payment card
ProcessesLook up the price, add to the running total, check the weight
OutputsItem name and price on screen, total, receipt
StorageProduct file of barcodes and prices, record of the sale
?Why?

Small parts are easier to write, test and fix. Different programmers can work on different sub-systems at the same time.

7.2 Systems, decomposition and design tools · The explanation · step 1 of 6 · part 3 of 3

Sub-systems, and inputs, processes, outputs and storage (continued)

!Watch out

Do not put the same thing in two places. 'Total' is calculated (process) and then shown (output). Say which one you mean.

7.2 Systems, decomposition and design tools · The explanation · step 2 of 6 · part 1 of 2

Structure diagrams

A structure diagram shows how a system is broken down into sub-systems. The whole system is in the top box.

Each level below shows smaller parts. Read it top to bottom. Boxes on one level are usually read from left to right.

It shows what the parts are, not the order of every step or the decisions.

7.2 Systems, decomposition and design tools · The explanation · step 2 of 6 · part 2 of 2

Structure diagrams (continued)

?Why?

A structure diagram is a picture of decomposition. It helps a team share out the work: one person can code 'Take payment' while another codes 'Update card'.

There is a diagram for this step in the IGCSE library.

7.2 Systems, decomposition and design tools · The explanation · step 3 of 6 · part 1 of 3

Flowcharts: the six symbols

A flowchart shows the steps of an algorithm as shapes joined by arrows. Each shape has one meaning.

Follow the flow lines from START to STOP. A decision diamond has two exits, labelled Yes and No.

A loop is drawn as a flow line that goes back up to an earlier step.

7.2 Systems, decomposition and design tools · The explanation · step 3 of 6 · part 2 of 3

Flowcharts: the six symbols (continued)

e.g.Example
Flowchart to count passes in 6 marks: START (terminator) → Count ← 0, Index ← 1 (process) → INPUT Mark (input/output) → Mark >= 25? (decision) Yes → Count ← Count + 1 (process); No → go on → Index ← Index + 1 (process) → Index > 6? (decision) No → back up to INPUT Mark; Yes → go on → OUTPUT Count (input/output) → STOP (terminator)

7.2 Systems, decomposition and design tools · The explanation · step 3 of 6 · part 3 of 3

Flowcharts: the six symbols (continued)

!Watch out

Use the right shape. INPUT and OUTPUT go in a parallelogram, not a rectangle. Every decision diamond needs two labelled exits.

There is a diagram for this step in the IGCSE library.

7.2 Systems, decomposition and design tools · The explanation · step 4 of 6 · part 1 of 4

Pseudocode: Cambridge's planning language

Pseudocode is a way of writing an algorithm that looks like code but is not tied to one language.

Cambridge has its own rules. Keywords are in CAPITALS. Assignment uses `←`. Comments start with `//`. Not equal is `<>`.

Paper 2 answers must be in pseudocode. Program code only earns marks in the 15-mark scenario question.

7.2 Systems, decomposition and design tools · The explanation · step 4 of 6 · part 2 of 4

Pseudocode: Cambridge's planning language (continued)

JobCambridge pseudocode
Make a variable`DECLARE Total : INTEGER`
Store a value`Total ← 0`
Input and output`INPUT Mark` and `OUTPUT "Total: ", Total`
Array of 30 items`DECLARE Marks : ARRAY[1:30] OF INTEGER`
Selection`IF … THEN … ELSE … ENDIF`
Count-controlled loop`FOR Index ← 1 TO 10` … `NEXT Index`
Pre-condition loop`WHILE … DO` … `ENDWHILE`
Post-condition loop`REPEAT` … `UNTIL …`

7.2 Systems, decomposition and design tools · The explanation · step 4 of 6 · part 3 of 4

Pseudocode: Cambridge's planning language (continued)

DECLARE Mark : INTEGER
OUTPUT "Enter your mark: "
INPUT Mark
IF Mark >= 25
  THEN
    OUTPUT "Pass"
  ELSE
    OUTPUT "Fail"
ENDIF

7.2 Systems, decomposition and design tools · The explanation · step 4 of 6 · part 4 of 4

Pseudocode: Cambridge's planning language (continued)

mark = int(input("Enter your mark: "))
if mark >= 25:
    print("Pass")
else:
    print("Fail")
?Why?

Pseudocode lets you think about the logic without worrying about the exact rules of Python. An examiner can read it whatever language you learned.

The explanation · 2 more steps

More on the lesson page

The lesson page has the rest of the explanation, step by step:

  • Stating the purpose
  • Describing the processes

Open the lesson page

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Quick quiz · 1 of 3

A diamond in a flowchart means…

  1. A A process
  2. B A decision
  3. C Input or output

B. A decision

Rectangle: process. Parallelogram: input or output. Diamond: a question with yes and no.

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Quick quiz · 2 of 3

Bubble sort stops when…

  1. A A whole pass makes no swaps
  2. B Half the list is sorted
  3. C The first swap happens

A. A whole pass makes no swaps

No swaps in a pass means everything is in order.

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Quick quiz · 3 of 3

The four stages of the program development life cycle are…

  1. A Input, process, output, storage
  2. B Fetch, decode, execute, store
  3. C Analysis, design, coding, testing

C. Analysis, design, coding, testing

Analyse the problem, design the solution, write the code, test it.

Year 10 · Computer Science · Algorithm design and problem solving · Lesson 2 of 5

Exit ticket

Answer on paper before you go. Then check.

  1. Abnormal test data is…

    A Data at the edge of the rangeB Typical dataC Data that should be rejected

    C. Data that should be rejected Normal works, abnormal is rejected, extreme sits on the edge, boundary is either side of it.

  2. A range check on age 0 to 120 would reject…

    A 150B 120C 0

    A. 150 0 and 120 are the edges and are allowed. 150 is outside.