Question 2(f)(ii) 2016 · May-June · Paper 22 · 2 marks
Reveal official mark-scheme answer
Official answer for Question 2
Part (f)
(ii)
(ii)
–
- Result, Exponent
- these variables change in the program
Show text version of question
Question 2
Part (f)
(ii)
Question 2
Ryan wrote the following recursive function using pseudocode.
01 FUNCTION Power(Number : INTEGER, Exponent : INTEGER) RETURNS INTEGER 02 IF Exponent = 0 03 THEN 04 Result ← 1 05 ELSE 06 Result ← Number * Power(Number, Exponent - 1) 07 ENDIF 08 RETURN Result 09 ENDFUNCTION Ryan uses his recursive function Power in a program. He will use debugging tools to check the Power function works as expected. The debugging tools include breakpoints, variable watches and stepping.
(ii)
Ryan wants to set up a variable watch window for his function.
01 FUNCTION Power(Number : INTEGER, Exponent : INTEGER) RETURNS INTEGER 02 IF Exponent = 0 03 THEN 04 Result ← 1 05 ELSE 06 Result ← Number * Power(Number, Exponent - 1) 07 ENDIF 08 RETURN Result 09 ENDFUNCTION
State the variable(s) that would be appropriate to list in the variable watch window. Justify your choice.
...........................................................................................................................................
...........................................................................................................................................
...........................................................................................................................................
......................................................................................................................................
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_s16_qp_22.pdf
