How do you design and present an algorithm using pseudocode and flowcharts?
Producing algorithms using pseudocode and flowcharts to solve a problem, identifying the inputs, processes and outputs, and interpreting, correcting and refining algorithms others have written.
An OCR J277 2.1.2 answer on designing algorithms with pseudocode and flowcharts: identifying inputs, processes and outputs, the OCR Exam Reference Language, the standard flowchart symbols, and interpreting, correcting and refining algorithms.
Reviewed by: AI editorial process; not yet individually human-reviewed
Have a quick question? Jump to the Q&A page
Jump to a section
What this dot point is asking
OCR wants you to design algorithms and present them in two forms, pseudocode and flowcharts, and to read, correct and refine algorithms written by others. You must identify the inputs, processes and outputs of a problem. Pseudocode in the exam is shown in the OCR Exam Reference Language, so you must recognise its notation. This is examined throughout Paper 2, including Section B.
Inputs, processes and outputs
For example, a program that works out the area of a rectangle has inputs (the length and width), a process (multiply length by width), and an output (the area). Naming them keeps the design focused.
Pseudocode and the OCR Exam Reference Language
A short ERL example that finds the largest of three numbers entered by the user:
a = int(input("First number: "))
b = int(input("Second number: "))
c = int(input("Third number: "))
largest = a
if b > largest then
largest = b
endif
if c > largest then
largest = c
endif
print("The largest is " + str(largest))
Flowcharts
The age-check algorithm as a flowchart:
Interpreting, correcting and refining
Refining an algorithm means improving it after it works, for example by making it handle invalid input, removing repeated code, or making it clearer. You are often asked to add validation or extend an algorithm to cover an extra case.
Try this
Q1. State the three things every algorithm can be described in terms of. [1 mark]
- Cue. Inputs, processes and outputs.
Q2. Name the flowchart symbol used for a decision, and state its shape. [1 mark]
- Cue. A decision, drawn as a diamond.
Q3. Write a pseudocode line that adds 1 to a variable called count. [1 mark]
- Cue.
count = count + 1.
Exam-style practice questions
Practice questions written in the style of OCR exam questions on this dot point, with worked answer explainers. The year tag is the paper they imitate, not the source.
OCR 20214 marksA program asks the user for their age, then prints whether they are an adult (18 or over) or a child. Write an algorithm for this, using pseudocode or a flowchart.Show worked answer →
Award marks for correct input, a correct condition, and the right output for each branch. A pseudocode answer in the OCR Exam Reference Language:
age = input("Enter your age: ")
if age >= 18 then
print("Adult")
else
print("Child")
endif
Marks: input into a variable (1), a selection using if ... then ... else ... endif (1), the correct comparison >= 18 (1), and the correct output on each branch (1). A flowchart with a parallelogram input, a diamond decision testing age >= 18, and two output boxes earns the same marks. Casting the input with int(...) is good practice and never penalised.
OCR 20223 marksAn algorithm is meant to add up the numbers from 1 to 10 and print the total, but it contains an error. Identify the error in the algorithm below and write the corrected line.
total = 0
for i = 1 to 10
total = i
next i
print(total)Show worked answer →
The error is on the line inside the loop: total = i overwrites the total with the current value of i each time, so it ends up holding 10, not the running sum.
The corrected line is total = total + i, which adds the current number to the running total each time round the loop, giving the correct answer of 55.
Markers reward correctly identifying the faulty line and giving the correct replacement that accumulates the total. Just saying "it is wrong" without the fix does not gain the correction mark.
Related dot points
- The principles of computational thinking: abstraction, decomposition and algorithmic thinking, and how each is used to analyse a problem and design a solution.
An OCR J277 2.1.1 answer on the principles of computational thinking: abstraction (removing unnecessary detail), decomposition (breaking a problem into smaller parts) and algorithmic thinking (a clear sequence of steps), with examples of how each is applied to a problem.
- Using trace tables to determine the output of an algorithm and to follow how the values of variables change, and determining the purpose of a simple algorithm.
An OCR J277 2.1.2 answer on using trace tables to follow an algorithm step by step, record how variable values change, find the output, and determine the purpose of a simple algorithm.
- Standard searching algorithms: linear search and binary search, how each works step by step, the requirement that binary search needs a sorted list, and the comparison of their efficiency.
An OCR J277 2.1.3 answer on the two standard searching algorithms: how linear search and binary search work step by step, why binary search needs a sorted list, and how their efficiency compares.
- Standard sorting algorithms: bubble sort, insertion sort and merge sort, how each works step by step, and how they compare in approach and efficiency.
An OCR J277 2.1.3 answer on the three standard sorting algorithms: how bubble sort, insertion sort and merge sort each put a list in order step by step, and how they compare in method and efficiency.
- The three basic programming constructs: sequence, selection (if and switch/case) and iteration (count-controlled for loops and condition-controlled while and do until loops), and when to use each.
An OCR J277 2.2.2 answer on the three programming constructs: sequence, selection (if and switch/case) and iteration (count-controlled for loops and condition-controlled while and do until loops), with the OCR Exam Reference Language for each.
Sources & how we know this
- OCR GCSE (9-1) Computer Science (J277) specification — OCR (2020)