Recursion vs iteration

Recursion vs iteration

Assessment

Interactive Video

Computers

12th Grade

Easy

Created by

Alexander Fraser

Used 1+ times

FREE Resource

7 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the purpose of a base case in a recursive function?

To terminate recursion and provide a way of returning to the previous call

To enhance the complexity of the function.
To provide a backup solution for errors.
To create additional recursive calls.

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What happens to a recursive function that calls itself indefinitely.

The function will run indefinitely without any issues.
The function will return a value immediately.
The function will cause a stack overflow error.
The function will execute faster with each call.

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the benefit here of using recursion over iteration?

Recursion is always faster than iteration.

Reduced lines of code to perform the same task

Recursion eliminates the need for any base case.
Recursion uses less memory than iteration.

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What do you notice about a difficulty with recursive algorithms from this example?

Recursive algorithms always run faster than iterative ones.
Recursive algorithms do not use any memory resources.
All recursive algorithms are guaranteed to terminate.

Recursive algorithms can be difficult to trace

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Recursive algorithms are good for when the program...

The result of the previous calculation can be fed into the next

should be avoided in all programming scenarios.
are best for linear data structures only.
are good for problems that require a single solution.

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which data structure is used to hold the contents of recursive calls?

Stack

Array
Linked List
Heap

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What data structure lends itself nicely to be used in recursion?

Array
Queue
Stack
Tree