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

Revision Note

Robert Hampton

Written by: Robert Hampton

Reviewed by: James Woodhouse

Explaining Algorithms

How do you explain an algorithm?

  • A well designed algorithm should be able to be interpreted by a new user and they should be able to explain what it does

  • Algorithms can be written using flowcharts, pseudocode or high-level programming language code such as Python

  • The purpose of an algorithm is to solve a problem, if a user does not know the goal of the algorithm, then following the algorithm instructions should make its purpose clear

  • If the algorithm is complex then additional ways to understand the problem could be:

    • Look for comments in the code

    • Consider the context of where the algorithm is being used

    • Test the algorithm with different inputs

  • Look at the following algorithm, can you explain what it does?

Pseudocode

Count ← 1

Number ← 0

Total ← 0

REPEAT

INPUT Number

Total ←  Total + Number

Count ← Count + 1

UNTIL Count > 10

OUTPUT Total

  • The purpose of the algorithm is to add ten user-entered numbers together and output the total

  • The processes are: 

    • initializing three variables (Count, Number, Total)

    • inputting a user number

    • adding to two variables (Total, Count) 

    • repeating nine more times

    • outputting the final Total value

Worked Example

The pseudocode algorithm shown has been written by a teacher to enter marks for the students in her class and then to apply some simple processing. 

Count ← 0

REPEAT 

INPUT Score[Count] 

IF Score[Count] >= 70 

THEN 

Grade[Count] ← "A" 

ELSE 

IF Score[Count] >= 60 

THEN 

Grade[Count] ← "B" 

ELSE 

IF Score[Count] >= 50 

   THEN 

Grade[Count] ← "C" 

ELSE 

IF Score[Count] >= 40 

   THEN 

Grade[Count] ← "D" 

ELSE 

IF Score[Count] >= 30 

   THEN 

Grade[Count] ← "E" 

ELSE 

Grade[Count] ← "F" 

ENDIF 

ENDIF 

ENDIF 

ENDIF 

ENDIF 

Count ← Count + 1 

UNTIL Count = 30 

Describe what happens in this algorithm. 

[3]

Answer

Any 3 of:

  • Inputted marks are stored in the array Score[] [1]

  • Marks are then checked against a range of boundaries [1]

  • A matching grade is assigned to each mark that has been input [1]

  • The grade is then stored in the array Grade[] [1]

  • At the same index as the inputted mark [1]

  • The algorithm finishes after 30 marks have been input [1]

Last updated:

You've read 0 of your 10 free revision notes

Unlock more, it's free!

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

Expertise: Computer Science Content Creator

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.

James Woodhouse

Author: James Woodhouse

Expertise: Computer Science

James graduated from the University of Sunderland with a degree in ICT and Computing education. He has over 14 years of experience both teaching and leading in Computer Science, specialising in teaching GCSE and A-level. James has held various leadership roles, including Head of Computer Science and coordinator positions for Key Stage 3 and Key Stage 4. James has a keen interest in networking security and technologies aimed at preventing security breaches.