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

Question 4(b) 2018 · October-November · Paper 43 · 6 marks

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

Official answer for Question 4

Part (b)

Question 1

mark for each bullet point:

Question 6

✓
•
  • 60 as final return value
✓
•
✓
3*2*1*–10
✓
1 mark for each row in table
✓
Call Number
✓
Function call
✓
Number = 0 ?
✓
Return value

Question 1

✓
Calculate(3)
✓
False
✓
3*Calculate(2)

Question 2

✓
Calculate(2)
✓
False
✓
2*Calculate(1)

Question 3

✓
Calculate(1)
✓
False
✓
1*Calculate(0)

Question 4

✓
Calculate(0)
✓
TRUE
  • 10

Mark scheme 9608_w18_ms_43.pdf →

Show text version of question

Question 4

Part (b)

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

Part (b)

The function is called with Calculate(3).

Dry run the function and complete the trace table below. State the final value returned. Show your working.

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

Working .....................................................................................................................................

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

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

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

Trace table:

Call number Function call Number = 0 ? Return value

Final return value ................................

[6]

Question 13

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