Past-paper question · 2019 May-June · Paper 22 · Q4(b)(ii)

Question 4(b)(ii) 2019 · May-June · Paper 22 · 2 marks

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

Official answer for Question 4

Part (b)

(ii)

✓
•
✓
Check the (final) value of NewString after the loop...

Question 2

✓
•
✓
...and see if it is greater than Selected (repeat the existing conditional clause)
✓
OR
✓
•
✓
Amend the algorithm to add a space character / non-numeric character to the
✓
end of the string...
✓
•
✓
...before the FOR loop / at the start of the function
✓
One mark per bullet point
✓
9608/22
✓
Cambridge International AS/A Level – Mark Scheme
✓
May/June 2019
✓
PUBLISHED
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_s19_ms_22.pdf →

Show text version of question

Question 4

Part (b)

(ii)

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

There is an error in the algorithm. When called as shown in part (a)(i), the function did not return the largest value as expected.

(ii)

Describe how the algorithm could be amended to correct the error.

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

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

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

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

[2]
Topic relevance

Why this question appears here

72% 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_s19_qp_22.pdf

Keep practising this topic