Past-paper question · 2019 May-June · Paper 21 · Q4(a)(i)

Question 4(a)(i) 2019 · May-June · Paper 21 · 6 marks

Original past-paper question for 4(A)(I)
Original past-paper question for 4(A)(I)
Reveal official mark-scheme answer Official mark-scheme answer for 4(A)(I)

Official answer for Question 4

Part (a)

(i)

Question 6

✓
Index
✓
AfterSpace
✓
NextChar
✓
NewString
✓
FALSE
✓
""

Question 1

✓
'X'
✓
"X"

Question 2

✓
TRUE
✓
'∇'
✓
"X∇"

Question 3

✓
'∇'
✓
'∇'

Question 4

✓
FALSE

Question 5

✓
'Y'
✓
"X∇Y"

Question 6

✓
TRUE
✓
'∇'
✓
"X∇Y∇"
✓
FALSE

Question 7

✓
‘a’
✓
"X∇Y∇a"

Question 8

✓
'n'
✓
"X∇Y∇an"

Question 9

✓
'd'
✓
"X∇Y∇and"

Question 10

✓
TRUE
✓
'∇'
✓
"X∇Y∇and∇"

Question 11

✓
'∇'

Question 12

✓
FALSE
✓
'Z'
✓
"X∇Y∇and∇Z"
✓
One mark for each area as outlined. If no row marks then mark by column
✓
for columns 2, 3 and 4

Mark scheme 9608_s19_ms_21.pdf →

Show text version of question

Question 4

Part (a)

(i)

Question 4

The following pseudocode is a string handling function.

For the built-in functions list, refer to the Appendix on page 16.

FUNCTION Clean(InString : STRING) RETURNS STRING

DECLARE NewString : STRING DECLARE Index : INTEGER DECLARE AfterSpace : BOOLEAN DECLARE NextChar : CHAR CONSTANT Space = ' '

AfterSpace FALSE NewString ""

FOR Index 1 TO LENGTH(InString) NextChar MID(InString, Index, 1) IF AfterSpace = TRUE THEN IF NextChar <> Space THEN NewString NewString & NextChar AfterSpace FALSE ENDIF ELSE NewString NewString & NextChar IF NextChar = Space THEN AfterSpace TRUE ENDIF ENDIF ENDFOR

RETURN NewString

ENDFUNCTION

Question 9

(i)

Complete the trace table by performing a dry run of the function when it is called as

follows:

Result Clean("X∇∇∇Y∇and∇∇Z")

The symbol '∇' represents a space character. Use this symbol to represent a space character in the trace table.

Index AfterSpace NextChar NewString

[6]
Topic relevance

Why this question appears here

71% assigned-topic match · Software development › Program testing and maintenance

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

Keep practising this topic