Edexcel GCSE Computer Science June 2023 Paper 1, Question 4: computational thinking

Pearson Edexcel 1CP2/01 June 2023, Question 4(c) to (e): complete a flowchart that reports odd or even using modulus, describe a linear search on an unsorted array for four marks, and complete the truth table for S AND M. Worked through, with the programs to run.

Past paper questionPearson 1CP2/01June 2023 Paper 120 marksExplain

Question 4 of the Pearson Edexcel GCSE Computer Science Paper 1 sat on 19 May 2023 (1CP2/01, Principles of Computer Science) is the computational thinking question, 20 marks. This page works through parts (c), (d) and (e): a flowchart, a description and a truth table.

We do not copy the paper here. Open it beside this page: Edexcel June 2023 Paper 1 question paper (PDF). When you have finished, check the mark scheme too.

Part (c): the odd or even flowchart (4 marks)

The user enters a whole number, positive or negative, and the algorithm reports whether it is even or odd. The paper reminds you that modulus gives the remainder after division. Start and Stop are drawn for you.

  1. Input the number (parallelogram).
  2. Decision (diamond): number MOD 2 == 0?
  3. Yes exit: output "Even". No exit: output "Odd".
  4. Both outputs join up and lead to Stop.

The four marks: an input symbol; a decision with exactly two labelled arrows; a correct test that matches the labels and outputs; and everything connected, with no loose symbol and each output leading to the terminator.

Negative numbers are the small trap. -7 MOD 2 in Python is 1, so the test still works. Nothing extra is needed.

Part (d): describe a linear search on an unsorted array (4 marks)

Four linked points:

  1. Start at the first item and go through the array in order.
  2. Compare each item with the target.
  3. Stop when the target is matched.
  4. Or stop when the end of the array is reached, which means the target is not there.

Unsorted matters: with no order, there is no way to stop early on "passed", so every item may have to be checked.

Part (e): the truth table for S AND M (2 marks)

A floodlight turns on when it is dark (S) and movement is sensed (M).

S M S AND M
0 0 0
0 1 0
1 0 0
1 1 1

One mark for the four different input rows, one for the results. Only 0 and 1 (or True and False) are accepted.

Where the marks are lost

  • A decision with one exit, or with arrows that are not labelled.
  • "Compare the target with the middle" in part (d). That is a binary search, and it needs a sorted array.
  • Three points instead of four. The end-of-array case is the one usually missed.
  • A repeated row in the truth table. Count in binary: 00, 01, 10, 11.

Run it

Odd or even, with negative numbers to try, then the four rows of the truth table.

Try 7, -7, 0 and 12. Then the floodlight table: only 1 1 turns it on.
The program
from bugbot import *
connect()

number = int(input("Enter a whole number: "))
if number % 2 == 0:
    led("green")
    print("Even")
else:
    led("blue")
    print("Odd")

print("S M  S AND M")
for S in [0, 1]:
    for M in [0, 1]:
        print(S, M, "", int(S and M))
Put this demo on your own site

Paste it into a school website, Moodle, Google Sites or a blog. More options on the embed page.

Questions

What is the answer to Edexcel 2023 Paper 1 Question 4(c)?

Input the number, then a decision testing number MOD 2 == 0. The Yes branch outputs Even, the No branch outputs Odd, and both lead to Stop.

How do you describe a linear search for four marks?

Start at the first item and work through the array in order, comparing each item with the target. Stop when a match is found, or when the end of the array is reached without one.

Why does a linear search work on an unsorted array?

Because it checks every item in turn and does not rely on any order. A binary search needs the array to be sorted first.

Every Edexcel 1CP2 question we have worked · Guide: Linear search and binary search explained

Learn it step by step

  1. F5.2 Flowcharts Algorithms
  2. F5.5 Linear search Algorithms
  3. F9.1 Logic gates and truth tables Logic and computer systems
Open the lessons

This is our own explanation of a published exam question. It is not written or endorsed by Pearson, and the question paper and mark scheme remain Pearson's copyright. Read them on Pearson's site with the links on this page.