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.

Host this setFree Play

The 20 questions

  1. What fundamental action defines a recursive subroutine in programming?

    • Using loops
    • Modifying arrays
    • Calling itself
    • Declaring globals
  2. What two essential components must any recursive subroutine contain?

    • Global and local variables
    • Base and recursive cases
    • Procedure and function
    • Loop and counter
  3. What is the main purpose of a base case in recursion?

    • Declaring variables
    • Allocating memory
    • Calling the function
    • Stopping the recursion
  4. 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
  5. What is 5! (factorial of 5)?

    • 60
    • 25
    • 15
    • 120
  6. What does the recursive function fact(n) return when n = 0, given the base case fact(0) = 1?

    • 0
    • 1
    • It loops forever
    • n
  7. 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
  8. What happens if a recursive function lacks a base case?

    • Infinite recursion
    • Immediate termination
    • Compilation error
    • Syntax failure
  9. Which feature makes a problem well suited to recursion?

    • Constant outcomes
    • Linear iteration
    • Self-similar subproblems
    • Sequential inputs
  10. What must each recursive step do to ensure termination?

    • Approach base case
    • Loop infinitely
    • Reset stack frames
    • Increase problem size
  11. Which memory structure is heavily used by recursion but not iteration?

    • Call stack
    • Disk storage
    • Heap memory
    • Static memory
  12. 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
  13. 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
  14. What must change between successive recursive calls to prevent an infinite loop?

    • Global constants
    • Function names
    • Return types
    • Parameter values
  15. What data is stored in the separate stack frame of a recursive call?

    • Global variables
    • Source code
    • Local variables
    • Bytecode instructions
  16. 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
  17. 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
  18. What part of a recursive function prevents infinite recursion from occurring?

    • Return address
    • General case
    • Stack frame
    • Base case
  19. What is the base case when recursively calculating string length?

    • Empty string
    • Single character
    • Full string
    • Null pointer
  20. What process passes returned values back through previous recursive subroutines?

    • Heap allocation
    • Stack unwinding
    • Stack pushing
    • Queue popping

All AQA Computer Science quizzes