Past-paper question · 2019 October-November · Paper 21 · Q6(c)

Question 6(c) 2019 · October-November · Paper 21 · 8 marks

Original past-paper question for 6(C)
Original past-paper question for 6(C)
Original past-paper question for 6(C)
Original past-paper question for 6(C)
Reveal official mark-scheme answer Official mark-scheme answer for 6(C)

Official answer for Question 6

Part (c)

✓
PROCEDURE FindDuplicates()

Question 8

✓
DECLARE
✓
Index : INTEGER
✓
DECLARE
✓
FileData : STRING
✓
DECLARE
✓
Continue : BOOLEAN
✓
DECLARE
✓
AccNum : STRING
✓
Index ← 1 // assuming array is [1:100]
✓
Continue ← TRUE
✓
OPENFILE "UserListAtoM.txt" FOR READ
✓
WHILE NOT EOF("UserListAtoM.txt") AND Continue = TRUE
✓
READFILE "UserListAtoM.txt", FileData
✓
IF MID(FileData, 7, 1) = ' * ' // six character reference
✓
THEN
✓
AccNum ← LEFT(FileData, 6)
✓
ELSE
✓
AccNum ← LEFT(FileData, 9)
✓
ENDIF
✓
IF SearchFileNtoZ(AccNum) = TRUE
✓
THEN
✓
IF Index = 101 // is the array already full?
✓
THEN
✓
OUTPUT "Error – Array Full"
✓
Continue ← FALSE
✓
ELSE
✓
Duplicates[Index] ← AccNum
✓
Index ← Index + 1
✓
ENDIF
✓
ENDIF
✓
ENDWHILE
✓
CLOSEFILE "UserListAtoM.txt"
✓
ENDPROCEDURE
✓
One mark for each of the following (max 8):
✓
1. Declaration and Initialisation of Index and used to index array
✓
Duplicates
✓
2. OPEN file UserListAtoM.txt in READ mode and CLOSE
✓
3. Pre-Condition loop to go through the file until EOF() and early termination
✓
if array full
✓
4. Read line from file and extract account number (AccNum) in a loop
✓
5. Call SearchFileNtoZ (with AccNum) following an attempt at MP4 in a
✓
loop
✓
6. Check if return value is TRUE and if so: in a loop
✓
7.
✓
store AccNum in correct array element
✓
8. increment array index following an attempt at MP7
✓
9. If array overflow OUTPUT error message
✓
9608/21
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2019
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w19_ms_21.pdf →

Show text version of question

Question 6

Part (c)

Question 6

Account information for users of a library is held in one of two text files; UserListAtoM.txt and

UserListNtoZ.txt

The format of the data held in the two files is identical. Each line of the file is stored as a string that contains an account number, name and telephone number separated by the asterisk character ('*') as follows:

<Account Number>'*'<Name>'*'<Telephone Number>

An example of one line from the file is:

"GB1234*Kevin Mapunga*07789123456"

The account number string may be six or nine characters in length and is unique for each person. It is made up of alphabetic and numeric characters only.

An error has occurred and the same account number has been given to different users in the two files. There is no duplication of account numbers within each individual file.

A
program is to be written to search the two files and to identify duplicate entries. The account

number of any duplicate found is to be written to an array, Duplicates, which is a 1D array of 100 elements of data type STRING.

The program is to be implemented as several modules. The outline description of three of these is as follows:

Module Outline description

ClearArray()

  • Initialise the global array Duplicates. Set all elements to the
  • empty string.

  • Read each line from the file UserListAtoM.txt
  • Check whether the account number appears in file
  • UserListNtoZ.txt using SearchFileNtoZ() FindDuplicates() • If the account number does appear then add the account number to the array.

  • Output an error message and exit the module if there are more
  • duplicates than can be written to the array.

  • Search for a given account number in file UserListNtoZ.txt
  • SearchFileNtoZ()

  • If found, return TRUE, otherwise return FALSE

Part (c)

Write pseudocode for the module FindDuplicates().

The module description is given in the table on page 12.

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

Question 15

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

...................................................................................................................................................

.............................................................................................................................................

[8]
Topic relevance

Why this question appears here

87% assigned-topic match · Data types and structures › Files

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_w19_qp_21.pdf

Keep practising this topic