Study the following pseudocode for a recursive function. FUNCTION Unknown (BYVAL X, BYVAL Y : INTEGER) RETURNS INTEGER IF $$\(X< Y\)$$ THEN OUTPUT X + Y RETURN (Unknown ( $$\(\mathrm{X}+1, \mathrm{Y})\)$$ * 2) ELSE IF $$\(X=Y\)$$ THEN RETURN 1 ELSE OUTPUT X + Y RETURN (Unknown (X - 1, Y) DIV 2) ENDIF ENDIF ENDFUNCTION The operator DIV returns the integer value after division e.g. 13 DIV 2 would give 6 The main program needs to run all three of the following function calls and output the result of each call: Unknown $$\((10,15)\)$$ Unknown $$\((10,10)\)$$ Unknown $$\((15,10)\)$$ (i) For each of the three function calls, the main program needs to: - output the value of the two parameters - call the function with those parameters - output the return value. Write the program code for the main program. (ii) Take a screenshot to show the output from part (b)(i).

Computer Science
IGCSE&ALevel
CAIE
Exam No:9618_w21_qp_42 Year:2021 Question No:1(b)

Answer:







Knowledge points:

19.2 Recursion

Solution:

Download APP for more features
1. Tons of answers.
2. Smarter Al tools enhance your learning journey.
IOS
Download
Android
Download
Google Play
Download