Past-paper question · 2015 May-June · Paper 43 · Q6(e)

Question 6(e) 2015 · May-June · Paper 43 · 5 marks

Original past-paper question for 6(E)
Original past-paper question for 6(E)
Original past-paper question for 6(E)
Original past-paper question for 6(E)
Reveal official mark-scheme answer Official mark-scheme answer for 6(E)

Official answer for Question 6

Part (e)

Part (e)

(i)

Example Pascal

✓
Procedure X(n: INTEGER)
✓
BEGIN
✓
IF (n = 0) OR (n = 1)
✓
THEN
✓
Write(n)
✓
ELSE
✓
BEGIN
✓
X(n DIV 2);
✓
Write(n MOD 2);
✓
END;
✓
END;
✓
Example Python
✓
def X(n):
✓
if (n == 0) or (n == 1):
✓
print(n, end="")
✓
else:
✓
X(n // 2)
✓
print(n % 2, end="")
✓
Mark as follows:
✓
Procedure heading & ending
✓
Boolean expression
✓
correctly grouped statements within ELSE
✓
recursive call
✓
Using DIV and MOD correctly
[5]

Mark scheme 9608_s15_ms_43.pdf →

Show text version of question

Question 6

Part (e)

Question 6

A recursively defined procedure X is defined below:

PROCEDURE X(BYVALUE n : INTEGER) IF (n = 0) OR (n = 1) THEN OUTPUT n ELSE CALL X(n DIV 2) OUTPUT (n MOD 2) ENDIF ENDPROCEDURE

Part (e)

Write program code for procedure X.

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

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

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

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

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

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

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

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

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

[5]

Question 16

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.

To avoid the issue of disclosure of answer-related information to candidates, all copyright acknowledgements are reproduced online in the Cambridge International Examinations Copyright Acknowledgements Booklet. This is produced for each series of examinations and is freely available to download at www.cie.org.uk after the live examination series.

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

71% assigned-topic match · Programming › Constructs

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

Keep practising this topic