Documentation for ITU AI Teacher Assistant Context
View the Project on GitHub frederico-alves/ITU-AI-Teacher-Assistant-Context
This quiz is about Recursion — a method of solving computational problems where the solution depends on smaller instances of the same problem.
Please note:
You must use only the resources assigned to your group:
Please indicate which experimental group you have been assigned to:
We are master’s students from IT University of Copenhagen conducting research for our thesis.
By participating, you confirm:
I hereby consent to my data being collected and used for research:
What is your gender?
Following code implements a recursive function that computes the factorial value of n.
Example: fac(3) = 6.
What is the sequence of recursive calls and their arguments, if we call fac(3)?
int fac(int n) {
if (n == 0) return 1;
return n * fac(n - 1);
}
Following code implements a recursive function that computes the factorial value of n.
Example: fac(3) = 6.
What is the sequence of return values from all recursive calls, if we call fac(3)?
int fac(int n) {
if (n == 0) return 1;
return n * fac(n - 1);
}
The following code implements a recursive function that computes the factorial value of n (n!).
Rewrite the code so that it computes the accumulated sum of n instead of the factorial value. Use recursion.
Example:
sum(3) = 6, since3 + 2 + 1 + 0 = 6.
int sum(int n) {
if (n == ...) return ...;
return n ... sum(n - 1);
}
| n | Calculation | Result |
|---|---|---|
| 0 | 0 | = 0 |
| 1 | 1 + 0 | = 1 |
| 2 | 2 + 1 + 0 | = 3 |
| 3 | 3 + 2 + 1 + 0 | = 6 |
You must implement a recursive function that computes the factorial value of n.
Example:
fact(3) = 6, since3 * 2 * 1 = 6.
int fac(int n) {
// your code here
}
| n | Expression | Result |
|---|---|---|
| 0 | 1 | = 1 |
| 1 | 1 | = 1 |
| 2 | 2 * 1 | = 2 |
| 3 | 3 * 2 * 1 | = 6 |
Thank you for participating in this quiz. Your responses are anonymous and will be used solely for research in the IT University of Copenhagen master’s thesis.
Would you like me to also convert this quiz into an interactive Markdown form (e.g., for GitHub Pages or Jupyter Notebook use, with radio buttons and text inputs)?