DSA (QUIZ 3) - Recursion

DSA (QUIZ 3) - Recursion

University

15 Qs

quiz-placeholder

Similar activities

CLC Lesson 4&5 Quiz

CLC Lesson 4&5 Quiz

University

12 Qs

Java_Quiz_Part_2

Java_Quiz_Part_2

University

12 Qs

Python_Quiz_1

Python_Quiz_1

University

10 Qs

Python: operadores y tipos de datos

Python: operadores y tipos de datos

University

18 Qs

P3 IAS 2 Quiz

P3 IAS 2 Quiz

University

15 Qs

Keyboard Shortcuts

Keyboard Shortcuts

5th Grade - University

11 Qs

OOP-Q1

OOP-Q1

University

10 Qs

Melaka 2024

Melaka 2024

University

10 Qs

DSA (QUIZ 3) - Recursion

DSA (QUIZ 3) - Recursion

Assessment

Quiz

Information Technology (IT)

University

Practice Problem

Medium

Created by

M'Alou Gonzales

Used 2+ times

FREE Resource

AI

Enhance your content in a minute

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

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the main difference between recursion and iteration in programming?

Recursion involves loops, while iteration involves function calls.

Recursion involves function calls, while iteration involves loops.

Recursion and iteration are the same.

Recursion is faster than iteration.

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following problems is best suited for a recursive solution?

Summing an array of integers

Printing 'Hello, World!' 10 times

Calculating the factorial of a number

Finding the maximum value in a list

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the base case in the recursive definition of the Fibonacci sequence?

F(n)=F(n−1)+F(n−2)F(n) = F(n-1) + F(n-2)

F(n)=nF(n) = n

F(0)=0F(0) = 0 and F(1)=1F(1) = 1

F(n)=2F(n−1)F(n) = 2F(n-1)

4.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

In the Tower of Hanoi problem, what is the minimum number of moves required to solve the puzzle with 5 disks?

15

31

63

127

5.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following is a correct recursive function to calculate the factorial of a number n?

def factorial(n): return n * factorial(n+1)

def factorial(n): if n == 0: return 1 else: return n * factorial(n-1)

def factorial(n): return n + factorial(n-1)

def factorial(n): return n * factorial(n-2)

6.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What is the time complexity of calculating the nth Fibonacci number using simple recursion?

O(n)

O(log n)

O(n^2)

O(2^n)

7.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Which of the following statements about recursion is false?

Recursive functions always have a base case.

Recursion can lead to stack overflow if not implemented correctly.

Recursion always results in more efficient algorithms than iteration.

Recursion can be used to solve problems that can be broken down into smaller subproblems.

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?