Recursion and Data Structures Quiz

Recursion and Data Structures Quiz

University

20 Qs

quiz-placeholder

Similar activities

MUN-Fact or FIB

MUN-Fact or FIB

6th Grade - Professional Development

22 Qs

Basic Dysrhythmia Quiz (Norton)

Basic Dysrhythmia Quiz (Norton)

University

25 Qs

JavaScript and React Quiz

JavaScript and React Quiz

University

20 Qs

Datastructure 1

Datastructure 1

University

20 Qs

Code nhanh

Code nhanh

University

21 Qs

Final Assessment C & C++ & DSA - 2nd August 24

Final Assessment C & C++ & DSA - 2nd August 24

University

25 Qs

Hash

Hash

University

20 Qs

Soft Skills

Soft Skills

University

15 Qs

Recursion and Data Structures Quiz

Recursion and Data Structures Quiz

Assessment

Quiz

Professional Development

University

Medium

Created by

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

Create resources
Host any resource
Get auto-graded reports
or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?

Discover more resources for Professional Development