Past-paper question · 2018 October-November · Paper 43 · Q4(c)(ii)

Question 4(c)(ii) 2018 · October-November · Paper 43 · 5 marks

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

Official answer for Question 4

Part (c)

(ii)

Question 1

mark per bullet point to max 5:

Question 5

✓
•
✓
Function header with parameter and Returning calculated value
✓
•
✓
Loop parameter times (up to number, or down from number)«
✓
•
✓
«Multiplying by loop counter
✓
•
✓
Multiplying by –10
✓
•
✓
Dealing with starting value correctly
✓
For example:
✓
FUNCTION Calculate(Number : INTEGER) RETURNS INTEGER
✓
DECLARE Count : INTEGER
✓
DECLARE Value : INTEGER
✓
Value ← −10
✓
FOR Count ← 1 to Number
✓
Value ← Value * Count
✓
ENDFOR
✓
RETURN Value
✓
ENDFUNCTION
✓
Question
✓
Answer
✓
Marks

Mark scheme 9608_w18_ms_43.pdf →

Show text version of question

Question 4

Part (c)

(ii)

Question 4

The recursive algorithm for the Calculate() function is defined as follows:

01 FUNCTION Calculate(BYVALUE Number : INTEGER) RETURNS INTEGER

02 IF Number = 0

03 THEN

04 Calculate −10

05 ELSE

06 Calculate Number * Calculate(Number − 1)

07 ENDIF

08 ENDFUNCTION

A
recursive algorithm within a subroutine can be replaced with an iterative algorithm.

(ii)

Rewrite the Calculate() function in pseudocode, using an iterative algorithm.

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

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

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

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

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

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

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

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

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

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

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

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

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

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

[5]

Question 14

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 9608_w18_qp_43.pdf

Keep practising this topic