Algorithms (Edexcel GCSE Computer Science): Exam Questions

Exam code: 1CP2

41 mins3 questions
1a3 marks

Here is an algorithm that uses colours.

Python code listing a colour array with a loop to print each colour. It prompts user input, commenting on the colour entered.

(i) Give the first line number of a condition‑controlled loop.

[1]

(ii) Give the first line number of iteration over every item in a data structure.

[1]

(iii) Give the line numbers of a selection.

[1]

1b3 marks

Programs can have syntax errors and runtime errors.

(i) Define the term ‘syntax error’.

[1]

(ii) Runtime errors happen when a program is executing.

Explain a runtime error.

[2]

1c3 marks

Algorithms use relational and arithmetic operators.

(i) Here is a relational operator used in a conditional test.

count > index

State the two different results of evaluating a conditional test.

[2]

(ii) Identify the result of 5 // 2

[1]

A. 0.5

B. 1

C. 2

D. 2.5

1d4 marks

Programmers consider algorithm efficiency when they write code.

(i) Sorting and searching use algorithms.

Complete the table with the name of a search algorithm and a sort algorithm.

[2]

Algorithm type

Characteristic

Algorithm name

Search

Is a divide and conquer algorithm

Sort

Is not a divide and conquer algorithm

(ii) Explain one effect the number of comparisons has on the execution time of a sorting algorithm.

[2]

2a2 marks

Programmers use trace tables with algorithms.

Explain the purpose of a trace table.

2b2 marks

Algorithms use arrays and records to hold data.

Describe a record.

2c4 marks

An algorithm allows users to enter a whole number.

The number can be positive or negative.

The purpose of the algorithm is to report whether the number is even or odd.

The modulus function returns the remainder after division.

The algorithm can be expressed as a flowchart.

Here are some flowchart symbols:

Diagram with flowchart symbols: rounded rectangle for Terminator, rectangle for Process, diamond for Decision, and parallelogram for Input/Output.

Complete the flowchart to show the algorithm.

You may not need to use all the flowchart symbols.

Flowchart with "Start" at the top leading to "Stop" at the bottom, enclosed in a dashed rectangular border, with vertical arrows.
2d4 marks

A linear search algorithm can be used on both a sorted and an unsorted array.

Describe how a linear search algorithm operates on an unsorted array.

3a2 marks

Here is an algorithm that prints colours.

Python script with variables for ink colours, a function to display them, and user input to choose whether to display colours or show a thank you.

(i) State the type of data structure used to hold the ink colours.

[1]

(ii) Give the contents of inkColours[2]

[1]

3b2 marks

This algorithm searches a sorted array of numbers for a target value.
The target value may or may not be in the array.

Code snippet of a while loop in Python checking conditions with index, found, and passed flags for searching a target in an array.

The use of the found variable helps to make the algorithm efficient.

Describe how the use of the passed variable also helps to make the algorithm efficient.

3c6 marks

Laura owns a fruit shop.

This program checks the weight of boxes of strawberries from Laura’s shop.

Python code snippet for a loop that inputs box weights, counts rejected boxes under 395 or over 405, and accepted ones, then prints results.

The inputs are 404, 393, 395, 405.

Complete the trace table showing the execution of the program with these inputs.

You may not need to fill in all the rows in the table.

count

accept

reject

weight

Display

3d6 marks

An algorithm is required that allows a user to enter two numbers. The algorithm then informs the user which number is greater, or whether the two numbers are equal. The algorithm is expressed in a flowchart.

Here are some flowchart symbols:

Flowchart symbols: Terminator (oval), Process (rectangle), Decision (diamond), Input/Output (parallelogram); each labelled accordingly.

Draw a flowchart to show this algorithm.