Lesson 4.1.1.16
4.1.1.16 Recursive techniques Quiz: AQA Computer Science, Unit 1
20 questions
In partnership with Revision Ninja
Lesson 4.1.1.16, Recursive techniques: 20 multiple choice questions for the AQA Computer Science (7517), Unit 1: Fundamentals of programming, written with Revision Ninja.
Host it live on the board and students join with a game code on their own devices, or revise alone with Free Play. The answers are revealed in the game.
The 20 questions
-
What fundamental action defines a recursive subroutine in programming?
- Using loops
- Modifying arrays
- Calling itself
- Declaring globals
-
What two essential components must any recursive subroutine contain?
- Global and local variables
- Base and recursive cases
- Procedure and function
- Loop and counter
-
What is the main purpose of a base case in recursion?
- Declaring variables
- Allocating memory
- Calling the function
- Stopping the recursion
-
Which expression is the standard recursive definition of factorial for n >= 1?
- n! = n * n
- n! = n + (n - 1)!
- n! = n * (n - 1)!
- n! = 1 for all n
-
What is 5! (factorial of 5)?
- 60
- 25
- 15
- 120
-
What does the recursive function fact(n) return when n = 0, given the base case fact(0) = 1?
- 0
- 1
- It loops forever
- n
-
A recursive function sumTo(n) returns n + sumTo(n - 1) with the base case sumTo(0) = 0. What is sumTo(4)?
- 10
- 6
- 24
- 4
-
What happens if a recursive function lacks a base case?
- Infinite recursion
- Immediate termination
- Compilation error
- Syntax failure
-
Which feature makes a problem well suited to recursion?
- Constant outcomes
- Linear iteration
- Self-similar subproblems
- Sequential inputs
-
What must each recursive step do to ensure termination?
- Approach base case
- Loop infinitely
- Reset stack frames
- Increase problem size
-
Which memory structure is heavily used by recursion but not iteration?
- Call stack
- Disk storage
- Heap memory
- Static memory
-
A recursive function counts down from n to 1 and prints each value. What is printed when called with n = 3?
- 3, 2, 1
- 3, 3, 3
- 2, 1
- 1, 2, 3
-
What is the result of power(2, 3) if power(x, n) = x * power(x, n - 1) with the base case power(x, 0) = 1?
- 8
- 5
- 6
- 9
-
What must change between successive recursive calls to prevent an infinite loop?
- Global constants
- Function names
- Return types
- Parameter values
-
What data is stored in the separate stack frame of a recursive call?
- Global variables
- Source code
- Local variables
- Bytecode instructions
-
A recursive function is used to calculate the sum of the digits of a number. For 123, which result is correct?
- 3
- 5
- 6
- 123
-
A recursive binary search splits a list in half each call. Roughly how many calls are needed for a list of 1024 items in the worst case?
- About 2
- About 10
- About 512
- About 1024
-
What part of a recursive function prevents infinite recursion from occurring?
- Return address
- General case
- Stack frame
- Base case
-
What is the base case when recursively calculating string length?
- Empty string
- Single character
- Full string
- Null pointer
-
What process passes returned values back through previous recursive subroutines?
- Heap allocation
- Stack unwinding
- Stack pushing
- Queue popping
Related quizzes
- Data types Quiz · 4.1.1.1 · 20 questions
- Programming concepts: sequence, selection and iteration Quiz · 4.1.1.2 · 20 questions
- Arithmetic operations Quiz · 4.1.1.3 · 20 questions
- Relational and Boolean operations Quiz · 4.1.1.4 · 20 questions
- Constants and variables Quiz · 4.1.1.6 · 20 questions
- String-handling operations Quiz · 4.1.1.7 · 20 questions
- Random numbers and exception handling Quiz · 4.1.1.8 · 20 questions
- Subroutines Quiz · 4.1.1.10 · 20 questions
- Parameters and returning values Quiz · 4.1.1.11 · 20 questions
- Local and global variables Quiz · 4.1.1.13 · 20 questions