Recursion and Data Structures Quiz

Recursion and Data Structures Quiz

University

20 Qs

quiz-placeholder

Similar activities

4° Sem |Test de diagnóstico

4° Sem |Test de diagnóstico

University

15 Qs

Application forms

Application forms

University

18 Qs

Grupos y Equipos

Grupos y Equipos

University

19 Qs

Examen AFNI

Examen AFNI

University

20 Qs

RETRAIN QUY ĐỊNH ĐÁNH THẺ QUÝ 1/ 2024

RETRAIN QUY ĐỊNH ĐÁNH THẺ QUÝ 1/ 2024

University

20 Qs

Direito do Consumidor

Direito do Consumidor

University

20 Qs

disturbi respiratori

disturbi respiratori

10th Grade - Professional Development

15 Qs

Recursion and Data Structures Quiz

Recursion and Data Structures Quiz

Assessment

Quiz

Professional Development

University

Practice Problem

Medium

Created by

Karnam Bharath

Used 3+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?