Difference between revisions of "2022 Paper 1 Revision Quiz"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
Line 69: Line 69:
 
{Look at this sample code:
 
{Look at this sample code:
  
  <nowiki>
+
  1: public int Fact(int num)
1: public int Fact(int num)
+
2: {
2: {
+
3:  if (num == 0)
3:  if (num == 0)
+
4:      return 1;
4:      return 1;
+
5:  else
5:  else
+
6:      return num * Fact(num-1);
6:      return num * Fact(num-1);
+
7: }
7: }
+
8:
8:
+
9:Fact(5);
9:Fact(5);</nowiki>
 
  
 
The function Fact is run with the parameter of 5.
 
The function Fact is run with the parameter of 5.

Revision as of 10:33, 2 June 2022

1. In Recursion, the part of the code which runs itself is called?

General Case.
Correct
Base Case.
Incorrect
Repeating Case.
Incorrect
Recursive Case.
Incorrect

2. In Recursion, the condition which stops the recursive calls is called?

General Case.
Correct
Base Case.
Incorrect
Repeating Case.
Incorrect
Recursive Case.
Incorrect

3. Look at this sample code:

1: public int Fact(int num)
2: {
3:   if (num == 0)
4:       return 1;
5:   else
6:       return num * Fact(num-1);
7: }

Which of these lines are the General Case?

3
Incorrect
4
Incorrect
5
Incorrect
6
Correct

4. Look at this sample code:

1: public int Fact(int num)
2: {
3:   if (num == 0)
4:       return 1;
5:   else
6:       return num * Fact(num-1);
7: }

Which of these lines are the Base Case?

3
Almost, this is the condition which causes the base case
4
Correct
5
Incorrect
6
Incorrect

5. Look at this sample code:

1: public int Fact(int num)
2: {
3:   if (num == 0)
4:       return 1;
5:   else
6:       return num * Fact(num-1);
7:

Your score is 0 / 0