stud
bud
Sign up
Log in
Home
Library
Explore
SAT
More
Recursion Quiz Flashcards | StudBud
Explore
/
Recursion Quiz
Recursion Quiz
20 terms
·
StudBud Administration
·
17 plays
Imported from external platform
Flashcards
20 cards
F
Practice quiz
P
Host live
L
Questions
20
Answers
1
Which data structure is used for recursion internally?
Stack
Array
Linked List
Queue
2
What happens if the base case of a recursive function is not defined?
The function cannot be defined
The program runs indefinitely
The program exits abruptly
The function executes successfully
3
What does each recursive function call do?
Executes the function in parallel
Pushes a frame to the call stack
Decreases the base case value
Allocates memory in the heap
4
Which of these problems is NOT typically solved using recursion?
Fibonacci number calculation
Tree traversal
Sorting algorithms like merge sort
String concatenation
5
What does the following C program compute?
The product of the first 5 natural numbers
The factorial of 5
The difference between 5 and 0
The sum of the first 5 natural numbers
6
What is mutual recursion?
Two functions calling each other in turns
A function calling itself directly
A function that doesn’t require a base ca
None of the above
7
Which of the following recursion types can lead to infinite loops if not handled correctly?
Both a and b
Direct recursion
Indirect recursion
None of the above
8
How can recursion be avoided in problems where memory usage is a concern?
Converting recursion to iteration
All of the above
Using memoization
Using tail recursion
9
In a recursive function, where is the return value stored?
Stack
Global memory
Heap
none of the above
10
Consider a recursive algorithm for calculating . How many calls are made for ?
7
4
5
6
11
What is recursion in programming?
a loop inside a function
a class inside a function
a function calling itself
a function calling another function
12
What is tail recursion?
A function that does not use recursion
A loop converted to recursion
A recursive function where recursion happens before other operations
A recursive function where recursion happens at the end
13
What will be the output of the following C program?
3 2 1 3 2 1
3 2 1 1 2 3
1 2 3
1 2 3 3 2 1
14
What will happen if a recursive function has multiple base cases, but none of them are met?
None of the above
The program will compile but not run
The function will terminate successfully
The function will enter infinite recursion
15
Which of the following is NOT a characteristic of recursion?
Recursive functions use stack memory
Recursion can always be replaced with iteration
Recursive functions must have a base case
Recursive solutions are always space-efficient
16
What is the main disadvantage of recursion over iteration?
Slower execution for all problems
Cannot be used for mathematical problems
Higher memory usage due to stack calls
Requires more lines of code
17
What is the maximum depth of recursion in most programming languages?
500
System-Dependent
10000
1000
18
Which of the following is true for recursion and iteration?
Recursion is always faster than iteration
Both use stack memory
Iteration uses more memory than recursion
Recursion uses stack memory, while iteration does not
19
Which of the following is necessary for a recursive function to work correctly?
iterative approach
nested function
base case
infinite loop
20
What is the base case in recursion?
The case where the function starts
The case where the function calls another function
The case where the function stops calling itself
The case where recursion does not work