Past-paper question · 2017 October-November · Paper 22 · Q3

Question 3 2017 · October-November · Paper 22 · 8 marks

Original past-paper question for 3
Original past-paper question for 3
Reveal official mark-scheme answer Official mark-scheme answer for 3

Official answer for Question 3

✓
Line
✓
Error
✓
Correction
✓
number
✓
Wrong procedure name
✓
01
✓
PROCEDURE ArraySort
  • "SortArray"
✓
02
✓
Wrong data type - CHAR
✓
DECLARE Temp: STRING
✓
DECLARE FirstID, SecondID, I, J :
✓
03
✓
Variables undefined
✓
INTEGER
✓
04
✓
Wrong 'Value2' of 100
✓
FOR I ← 1 TO 99
✓
05
✓
Wrong range
✓
FOR J ← 1 TO (100 – I)
✓
Wrong function -
✓
Replace MODULUS with TONUM:
✓
06/07
✓
MODULUS
✓
FirstID ← TONUM(LEFT(Product[J],
✓
Should be 4:
✓
06/07
✓
Wrong value of 6
✓
FirstID ← TONUM(LEFT(Product[J],
✓
Assigning wrong value

Mark scheme 9608_w17_ms_22.pdf →

Show text version of question

Question 3

A
1D array, Product, of type STRING is used to store information about a range of products in a

shop. There are 100 elements in the array. Each element stores one data item.

The format of each data item is as follows:

<ProductID><ProductName>

  • ProductID is a four-character string of numerals
  • ProductName is a variable-length string

The following pseudocode is an initial attempt at defining a procedure, ArraySort, which will perform a bubble sort on Product. The array is to be sorted in ascending order of ProductID. Line numbers have been added for identification purposes only.

01 PROCEDURE SortArray 02 DECLARE Temp : CHAR 03 DECLARE FirstID, SecondID : INTEGER 04 FOR I 1 TO 100 05 FOR J 2 TO 99 06 FirstID MODULUS(LEFT(Product[J], 6)) 07 SecondID MODULUS(LEFT(Product[J + 1], 6)) 08 IF FirstID > SecondID 09 THEN 10 Temp Product[I] 11 Product[I] Product[J + 1] 12 Product[J + 1] Temp 13 ENDFOR 14 ENDIF 15 ENDFOR 16 ENDPROCEDURE

Question 9

The pseudocode on page 8 contains a number of errors. Complete the following table to show:

  • the line number of the error
  • the error itself
  • the correction that is required.

Note:

  • If the same error occurs on more than one line, you should only refer to it ONCE.
  • Lack of optimisation should not be regarded as an error.

Line Error Correction number

01 Wrong procedure name – “SortArray” PROCEDURE ArraySort

[8]

Question 10

Topic relevance

Why this question appears here

82% assigned-topic match · Data types and structures › Data types and records

Topic-match percentages estimate how closely each question fits the selected syllabus topic. They are a guide for choosing stricter or broader practice.

Permanent source page: Educate A Change · From 9608_w17_qp_22.pdf

Keep practising this topic