# YOU CAN DOWNLOAD 200+ SUBJECTS PDF BOOK FOR COMPETITIVE EXAMINATIONS

## Data Structure Questions and Answers-Fibonacci using Recursion

Question 1 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Suppose the first fibonnaci number is 0 and the second is 1. What is the sixth fibonnaci number?

5 | |

6 | |

7 | |

8 |

Question 1 Explanation:

The sixth fibonnaci number is 5.

Question 2 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Which of the following is not a fibonnaci number?

8 | |

21 | |

55 | |

14 |

Question 2 Explanation:

14 is not a fibonnaci number.

Question 3 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Which of the following methods can be used to find the nth fibonnaci number?

Dynamic programming | |

Recursion | |

Iteration | |

All of the mentioned |

Question 3 Explanation:

All of the above mentioned methods can be used to find the nth fibonacci number.

Question 4 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Consider the following iterative implementation to find the nth fibonacci number:

int main() { int n = 10, i; if(n == 1) printf("0"); else if(n == 2) printf("1"); else { int a = 0, b = 1, c; for(i = 3; i <= n; i++) { c = a + b; .....; .....; } printf("%d", c); } return 0; }

Which of the following lines should be added to complete the above code?

c = b b = a | |

a = b b = c | |

b = c a = b | |

a = b b = a |

Question 4 Explanation:

The lines "a = b" and "b = c" should be added to complete the above code.

Question 5 [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER] |

Which of the following recurrence relations can be used to find the nth fibonacci number?

F(n) = F(n) + F(n - 1) | |

F(n) = F(n) + F(n + 1) | |

F(n) = F(n - 1) | |

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

Question 5 Explanation:

The relation F(n) = F(n - 1) + F(n - 2) can be used to find the nth fibonacci number.

There are 5 questions to complete.