Past-paper question · 2014 May-June · Paper 22 · Q4

Question 4 2014 · May-June · Paper 22 · 17 marks

Original past-paper question for 4
Original past-paper question for 4
Original past-paper question for 4
Reveal official mark-scheme answer Official mark-scheme answer for 4

Official answer for Question 4

✓
Y('E')
✓
'E'

Question 1

✓
'E'
✓
(3)
✓
'T'
✓
'ET'
✓
(2)
✓
'Y'
✓
'ETY'
✓
(1)
✓
'B'
✓
'ETYB'

Mark scheme 9691_s14_ms_22.pdf →

Show text version of question

Question 4

Look at this pseudocode function:

FUNCTION Y(s : STRING) RETURNS STRING DECLARE x : INTEGER x LENGTH(s) IF x = 1 THEN RETURN s ELSE RETURN Y(RIGHT(s, x - 1)) + LEFT(s, 1) // RIGHT above returns rightmost x - 1 characters of string s // LEFT above returns leftmost character of string s ENDIF ENDFUNCTION

(i)

How can you tell that function Y is recursive?

[1]

(ii)

Dry-run the function when it is called with the string ‘BYTE’ as parameter.

Call s x RIGHT (s, x - 1) LEFT (s, 1) Function call Return value Number

1 Y ('BYTE') 'BYTE'

[7]

(iii)

What does function Y do?

[1]

(iv)

List two features of the pseudocode above that make it easier to understand.

Question 1

Question 2

[2]

Question 11

(v)

List one feature of the pseudocode above that makes it more difficult to understand.

Question 1

[1]

(vi)

Re-write the pseudocode function as an iterative function.

FUNCTION Y(s : STRING) RETURNS STRING

ENDFUNCTION

[5]

Question 12

reasonable effort has been made by the publisher (UCLES) to trace copyright holders, but if any items requiring clearance have unwittingly been included, the publisher will be pleased to make amends at the earliest possible opportunity.

Cambridge International Examinations is part of the Cambridge Assessment Group. Cambridge Assessment is the brand name of University of Cambridge Local Examinations Syndicate (UCLES), which is itself a department of the University of Cambridge.

Topic relevance

Why this question appears here

98% assigned-topic match · Computational thinking and problem-solving › Recursion

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 9691_s14_qp_22.pdf

Keep practising this topic