Skip to main content

Back to the full dot-point answer

SingaporeComputer ScienceQuick questions

Algorithms and Problem Solving

Quick questions on Recursion and divide and conquer explained: H2 Computing

5short Q&A pairs drawn directly from our worked dot-point answer. For full context and worked exam questions, read the parent dot-point page.

What is the call stack?
Show answer
Each call is pushed onto the call stack, holding its own parameters and local variables. When a call reaches the base case it returns, and the stack unwinds, each waiting call completing with the returned value. Tracing recursion means writing out the calls going down, then the returns coming back up.
What is not reducing the input?
Show answer
Calling the function on the same or a larger input never reaches the base case; the argument must shrink each call.
What is q1?
Show answer
State what every recursive function must contain to avoid infinite recursion. [1 mark]
What is q2?
Show answer
What happens if a recursive function never reaches its base case? [1 mark]
What is q3?
Show answer
Give one reason to prefer iteration over recursion for a simple repeated calculation. [2 marks]

Have a question we have not covered?

This dot-point answer is short enough that we have not extracted many short questions yet. Read the full dot-point answer or ask Mo, our study assistant, in the chat for follow ups.

All Computer ScienceQ&A pages