# Welcome to the Dynamic Programming MCQs Page

Dive deep into the fascinating world of Dynamic Programming with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Dynamic Programming, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Dynamic Programming, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

Check out the MCQs below to embark on an enriching journey through Dynamic Programming. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Dynamic Programming. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

### Dynamic Programming MCQs | Page 1 of 22

Q1.
Which of the following is/are property/properties of a dynamic programming problem?
Answer: (d).Both optimal substructure and overlapping subproblems
Q2.
The following sequence is a fibonacci sequence:
0, 1, 1, 2, 3, 5, 8, 13, 21,…..

Which technique can be used to get the nth fibonacci term?
Q3.
Consider the recursive implementation to find the nth fibonacci number:
Which line would make the implementation complete?
int fibo(int n)
if n <= 1
return n
return __________
Answer: (d).fibo(n – 1) + fibo(n – 2)
Q4.
What is the time complexity of the recursive implementation used to find the nth fibonacci term?
Q5.
Suppose we find the 8th term using the recursive implementation. The arguments passed to the function calls will be as follows:

fibonacci(8)

fibonacci(7) + fibonacci(6)

fibonacci(6) + fibonacci(5) + fibonacci(5) + fibonacci(4)

fibonacci(5) + fibonacci(4) + fibonacci(4) + fibonacci(3) + fibonacci(4) + fibonacci(3) + fibonacci(3) + fibonacci(2)

:

:

:

Which property is shown by the above function calls?
Q6.
What is the output of the following program?
#include<stdio.h>
int fibo(int n)
{
if(n<=1)
return n;
return fibo(n-1) + fibo(n-2);
}
int main()
{
int r = fibo(50000);
printf("%d",r);
return 0;
}

Q7.
What is the space complexity of the recursive implementation used to find the nth fibonacci term?
Q8.
Consider the following code to find the nth fibonacci term.
Complete the below code.
int fibo(int n)
if n == 0
return 0
else
prevFib = 0
curFib = 1
for i : 1 to n-1
nextFib = prevFib + curFib
__________
__________
return curFib
curFib = nextFib
Q9.
What will be the output when the following code is executed?
#include<stdio.h>
int fibo(int n)
{
if(n==0)
return 0;
int i;
int prevFib=0,curFib=1;
for(i=1;i<=n-1;i++)
{
int nextFib = prevFib + curFib;
prevFib = curFib;
curFib = nextFib;
}
return curFib;
}
int main()
{
int r = fibo(10);
printf("%d",r);
return 0;
}

Q10.
Consider the following code to find the nth fibonacci term using dynamic programming:
Which property is shown by line 7 of the below code?
1.   int fibo(int n)
2.   int fibo_terms  //arr to store the fibonacci numbers
3.   fibo_terms = 0
4.   fibo_terms = 1
5.
6.   for i: 2 to n
7.  fibo_terms[i] = fibo_terms[i - 1] + fibo_terms[i - 2]
8.
9.   return fibo_terms[n]