DSA (QUIZ 3) - Recursion

Quiz
•
Information Technology (IT)
•
University
•
Medium
M'Alou Gonzales
Used 2+ times
FREE Resource
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.
Create a free account and access millions of resources
Similar Resources on Wayground
18 questions
Codean - Java Rekursi

Quiz
•
University
20 questions
Mastering Algorithmic Challenges

Quiz
•
University
15 questions
LATIHAN 1 - Hardware

Quiz
•
1st Grade - University
10 questions
Chapter 2 : Understanding and Modeling Organizational Systems

Quiz
•
University
20 questions
Programming Paradigms Quiz

Quiz
•
University
10 questions
Ôn tập - Hệ thống tự động hóa - Robotics

Quiz
•
9th Grade - University
18 questions
Recursividad: Pensá en pasos más simples

Quiz
•
University
20 questions
Decode the Tech Emoji

Quiz
•
University
Popular Resources on Wayground
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
10 questions
Nouns, nouns, nouns

Quiz
•
3rd Grade
10 questions
9/11 Experience and Reflections

Interactive video
•
10th - 12th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
11 questions
All about me

Quiz
•
Professional Development
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
9 questions
Tips & Tricks

Lesson
•
6th - 8th Grade
Discover more resources for Information Technology (IT)
21 questions
Spanish-Speaking Countries

Quiz
•
6th Grade - University
20 questions
Levels of Measurements

Quiz
•
11th Grade - University
7 questions
Common and Proper Nouns

Interactive video
•
4th Grade - University
12 questions
Los numeros en español.

Lesson
•
6th Grade - University
7 questions
PC: Unit 1 Quiz Review

Quiz
•
11th Grade - University
7 questions
Supporting the Main Idea –Informational

Interactive video
•
4th Grade - University
12 questions
Hurricane or Tornado

Quiz
•
3rd Grade - University
7 questions
Enzymes (Updated)

Interactive video
•
11th Grade - University