Past-paper question · 2017 October-November · Paper 23 · Q3(b)

Question 3(b) 2017 · October-November · Paper 23 · 8 marks

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

Official answer for Question 3

Part (b)

✓
Pseudocode solution included here for development and clarification of mark scheme.
✓
Programming language example solutions appear in the Appendix.
✓
PROCEDURE FindRepeats
✓
DECLARE i, RepeatCount: INTEGER
✓
DECLARE FirstID, SecondID: STRING
✓
RepeatCount ← 0
✓
FOR i ← 2 TO 100
✓
FirstID ← LEFT(UserNameArray[i – 1],6)
✓
SecondID ← LEFT(UserNameArray[i],6)
✓
IF FirstID = SecondID
✓
THEN
✓
RepeatCount ← RepeatCount + 1
✓
OUTPUT(UserNameArray[i])
✓
ENDIF
✓
ENDFOR
✓
IF RepeatCount = 0
✓
THEN
✓
OUTPUT "The array contains no repeated UserIDs"
✓
ELSE
✓
OUTPUT "There are " & RepeatCount & " repeated userIDs"
✓
ENDIF
✓
ENDPROCEDURE
✓
Mark as follows (all must be correct syntax for chosen language):
✓
1.
✓
Procedure heading and ending
✓
2.
✓
Variable declaration for INTEGER (comment in Python) and initialisation for
✓
RepeatCount (or equivalent name)
✓
3.
✓
Loop
✓
4.
✓
Extraction of UserID in a loop
✓
5.
✓
Correct comparison of consecutive elements« in a loop
✓
6.
✓
...output correct array element (NOT original, only duplicates) in a loop
✓
7.
✓
increment RepeatCount following a comparison in a loop
✓
8.
✓
Correct conditional statement checking RepeatCount (or equivalent) and then ...
✓
... two correct final OUTPUT statements
✓
9608/23
✓
Cambridge International AS/A Level – Mark Scheme
✓
October/November
✓
PUBLISHED
✓
2017
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w17_ms_23.pdf →

Show text version of question

Question 3

Part (b)

Part (b)

The value of UserID should be unique for each user but a problem has occurred and

repeated UserID values may have been issued.

The array is sorted by UserID, so any repeated UserID values will appear in consecutive array elements.

A
procedure, FindRepeats is required.

This will:

  • compare each element with the previous element and output the UserID and UserName
  • if the UserID is repeated

  • output the total number of UserIDs that are repeated.

For example, the UserNameArray contains the following entries.

Array element Comment

122222Jim Moriarty

123456Fred Smith 123456Eric Sykes Repeated User ID 123456Kevin Turvey Repeated User ID

222244Alice Chan 222244Myra Singh Repeated User ID

333333Yasmin Halim

For this example, the output is:

123456Eric Sykes 123456Kevin Turvey 222244Myra Singh There are 3 repeated UserIDs

If no repeated UserIDs are found, the output is:

The array contains no repeated UserIDs

Question 9

Write program code for the procedure, FindRepeats. You should assume that UserNameArray has been declared as a global variable.

Visual Basic and Pascal: You should include the declaration statements for variables. Python: You should show a comment statement for each variable used with its data type.

Programming language ............................................................................................................

Program code

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

...............................................................................................................................................[8]

Question 10

Topic relevance

Why this question appears here

82% assigned-topic match · Hardware › Logic gates and logic circuits

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

Keep practising this topic