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

Question 4(a)(i) 2019 · May-June · Paper 22 · 5 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 5

✓
Index
✓
NextChar
✓
Selected
✓
NewValue
✓
NewString
✓
0
✓
"0"

Question 1

✓
'1'
✓
"01"

Question 2

✓
'2'
✓
"012"

Question 3

✓
'∇'

Question 12

Question 12

✓
"0"

Question 4

✓
'3'
✓
"03"

Question 5

✓
'4'
✓
"034"

Question 6

✓
'∇'

Question 34

Question 34

✓
"0"

Question 7

✓
'5'
✓
"05"

Question 8

✓
'∇'

Question 5

✓
"0"

Question 9

✓
'∇'
✓
0
✓
"0"

Question 10

✓
'3'
✓
"03"

Question 11

✓
'9'
✓
"039"
✓
One mark for each column.
✓
If no mark for columns, award one mark for initialisation of Selected to 0 and
✓
Newstring to ‘0’ (single or double quotes).

Mark scheme 9608_s19_ms_22.pdf →

Show text version of question

Question 4

Part (a)

(i)

Question 4

The following is pseudocode for a string handling function.

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

FUNCTION Search(InString : STRING) RETURNS INTEGER

DECLARE NewString : STRING DECLARE Index : INTEGER DECLARE NextChar : CHAR DECLARE Selected : INTEGER DECLARE NewValue : INTEGER

NewString '0' Selected 0

FOR Index 1 TO LENGTH(InString)

NextChar MID(InString, Index, 1) IF NextChar < '0' OR NextChar > '9' THEN NewValue STRING_TO_NUM(NewString) IF NewValue > Selected THEN Selected NewValue ENDIF NewString '0' ELSE NewString NewString & NextChar ENDIF

ENDFOR

RETURN Selected

ENDFUNCTION

Question 9

(i)

The following assignment calls the Search() function:

Result Search("12∇34∇5∇∇39")

Complete the following trace table by performing a dry run of this function call.

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

Index NextChar Selected NewValue NewString

[5]
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_22.pdf

Keep practising this topic