
Recursion and Data Structures Quiz

Quiz
•
Professional Development
•
University
•
Medium
Karnam Bharath
Used 2+ times
FREE Resource
20 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the base case in recursion?
The case where the function calls itself
The condition that stops further recursive calls
The first step in the recursive function
A case where infinite recursion occurs
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What happens if a recursive function lacks a proper base case?
It will execute normally
It will result in infinite recursion leading to a stack overflow
It will execute but return None
It will compile but not run
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Consider the following recursive function: def mystery(n): if n == 0: return 1 return n * mystery(n - 1) What does mystery(5) return?
5
24
120
25
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following recursive functions correctly calculates the sum of digits of a number?
def sum_of_digits(n): return sum_of_digits(n // 10) + n % 10
def sum_of_digits(n): if n == 0: return 0 return sum_of_digits(n // 10) + n % 10
def sum_of_digits(n): if n < 0: return 0 return sum_of_digits(n - 1) + n % 10
None of the above
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which data structure is used for handling recursive function calls internally?
Queue
Stack
Linked List
Heap
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the time complexity of a naive recursive Fibonacci function?
O(n)
O(n²)
O(2ⁿ)
O(log n)
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which of the following approaches optimizes recursive Fibonacci using memoization?
Storing computed values in an array and reusing them
Using a loop instead of recursion
Using an explicit stack
Removing the base case
Create a free account and access millions of resources
Similar Resources on Wayground
15 questions
DAY 25 Array & Linked List in Data Structure (12th July 24)

Quiz
•
University
17 questions
Planeación didáctica

Quiz
•
University
24 questions
java

Quiz
•
University
25 questions
Data Structures: Stack,Queue and Binary Tree

Quiz
•
University
15 questions
Uso de PET reciclado em embalagens e outros materiais

Quiz
•
University
22 questions
화학 반응식 퀴즈

Quiz
•
9th Grade - University
25 questions
Final Assessment C & C++ & DSA - 2nd August 24

Quiz
•
University
15 questions
DAY 32 - Complexity Analysis & Big O Notations-23rd July 24

Quiz
•
University
Popular Resources on Wayground
55 questions
CHS Student Handbook 25-26

Quiz
•
9th Grade
18 questions
Writing Launch Day 1

Lesson
•
3rd Grade
10 questions
Chaffey

Quiz
•
9th - 12th Grade
15 questions
PRIDE

Quiz
•
6th - 8th Grade
40 questions
Algebra Review Topics

Quiz
•
9th - 12th Grade
22 questions
6-8 Digital Citizenship Review

Quiz
•
6th - 8th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade