Designing Algorithms (Cambridge (CIE) O Level Computer Science)

Revision Note

Robert Hampton

Expertise

Computer Science Content Creator

What is an algorithm?

  • An algorithm is precise set of rules or instructions to solve a specific problem or task

  • There are three main ways to design an algorithm

    • Structure diagrams

    • Flowchart

    • Pseudocode

Structure Diagrams

What is a structure diagram?

  • Structure diagrams show hierarchical top-down design in a visual form

  • Each problem is divided into sub-problems and each sub-problem divided into further sub-problems

  • At each level the problem is broken down into more detailed tasks that can be implemented using a single subroutine

unnamed-3
  • an example of a structure diagram for a mobile application could be:

unnamed-4

Flowcharts

What is a flowchart?

  • Flowcharts are a visual tool that uses shapes to represent different functions to describe an algorithm

  • Flowcharts show the data that is input and output, the processes that take place and any decisions or repetition

  • Lines are used to show the flow of control

flow-chart-symbols

Example

Flowchart

flow-chart-1
  • The casino would like the algorithm refined so that the user also enters their first name and this is used to greet the user when they access the site

Flowchart

flow-chart-2-1

Pseudocode

What is pseudocode?

  • Pseudocode is a text-based tool that uses short English words/statements to describe an algorithm

  • Pseudocode is more structured than writing sentences in English but is very flexible

Example

  • A casino would like a program that asks users to enter an age, if they are 18 or over they can enter the site, if not then they are given a suitable message

Pseudocode

INPUT Age

IF Age >= 18

THEN

OUTPUT "Welcome to the site"

ELSE

OUTPUT "Sorry, this site is for users 18 and over"

  • The casino would like the algorithm refined so that the user also enters their first name and this is used to greet the user when they access the site

Pseudocode

INPUT FName

INPUT Age

IF Age >= 18

THEN

OUTPUT "Welcome to the site", FName

ELSE

OUTPUT "Sorry, this site is for users 18 and over"

You've read 0 of your 0 free revision notes

Get unlimited access

to absolutely everything:

  • Downloadable PDFs
  • Unlimited Revision Notes
  • Topic Questions
  • Past Papers
  • Model Answers
  • Videos (Maths and Science)

Join the 100,000+ Students that ❤️ Save My Exams

the (exam) results speak for themselves:

Did this page help you?

Robert Hampton

Author: Robert Hampton

Rob has over 16 years' experience teaching Computer Science and ICT at KS3 & GCSE levels. Rob has demonstrated strong leadership as Head of Department since 2012 and previously supported teacher development as a Specialist Leader of Education, empowering departments to excel in Computer Science. Beyond his tech expertise, Robert embraces the virtual world as an avid gamer, conquering digital battlefields when he's not coding.