

MCQOPTIONS
Saved Bookmarks
This section includes 12 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structures and Algorithms knowledge and support exam preparation. Choose a topic below to get started.
1. |
How many times will the function fibo() be called when the following code is executed? |
A. | 5 |
B. | 6 |
C. | 8 |
D. | 9View Answer |
Answer» E. | |
2. |
What is the space complexity of the following recursive implementation to find the nth fibonacci number? |
A. | O(1) |
B. | O(2*n) |
C. | O(n2) |
D. | O(2n)View Answer |
Answer» B. O(2*n) | |
3. |
What is the time complexity of the following recursive implementation to find the nth fibonacci number? |
A. | O(1) |
B. | O(2*n) |
C. | O(n2) |
D. | O(2n)View Answer |
Answer» E. | |
4. |
Consider the following recursive implementation to find the nth fibonnaci number: Which of the following is the base case? |
A. | if(n == 1) |
B. | else if(n == 2) |
C. | return fibo(n – 1) + fibo(n – 2) |
D. | both if(n == 1) and else if(n == 2)View Answer |
Answer» E. | |
5. |
Consider the following recursive implementation to find the nth fibonacci number: Which of the following lines should be inserted to complete the above code? |
A. | fibo(n – 1) |
B. | fibo(n – 1) + fibo(n – 2) |
C. | fibo(n) + fibo(n – 1) |
D. | fibo(n – 2) + fibo(n – 1)View Answer |
Answer» C. fibo(n) + fibo(n – 1) | |
6. |
Which of the following recurrence relations can be used to find the nth fibonacci number? |
A. | F(n) = F(n) + F(n – 1) |
B. | F(n) = F(n) + F(n + 1) |
C. | F(n) = F(n – 1) |
D. | F(n) = F(n – 1) + F(n – 2) |
Answer» E. | |
7. |
What is the time complexity of the above recursive implementation to find the nth fibonacci number?$ |
A. | O(1) |
B. | O(2*n) |
C. | O(n<sup>2</sup>) |
D. | O(2<sup>n</sup>) |
Answer» D. O(2<sup>n</sup>) | |
8. |
What_is_the_space_complexity_of_the_above_recursive_implementation_to_find_the_nth_fibonacci_number? |
A. | O(1) |
B. | O(2*n) |
C. | O(n<sup>2</sup>) |
D. | O(2<sup>n</sup>) |
Answer» E. | |
9. |
Which of the following recurrence relations can be used to find the nth fibonacci number? |
A. | F(n) = F(n) + F(n – 1) |
B. | F(n) = F(n) + F(n + 1) |
C. | F(n) = F(n – 1) |
D. | F(n) = F(n – 1) + F(n – 2) |
Answer» C. F(n) = F(n ‚Äö√Ñ√∂‚àö√ë‚àö¬® 1) | |
10. |
Which of the following methods can be used to find the nth fibonnaci number? |
A. | Dynamic programming |
B. | Recursion |
C. | Iteration |
D. | All of the mentioned |
Answer» E. | |
11. |
Which of the following is not a fibonnaci number? |
A. | 8 |
B. | 21 |
C. | 55 |
D. | 14 |
Answer» E. | |
12. |
Suppose the first fibonnaci number is 0 and the second is 1. What is the sixth fibonnaci number? |
A. | 5 |
B. | 6 |
C. | 7 |
D. | 8 |
Answer» B. 6 | |