**DOWNLOAD FREE PDF** **<<CLICK HERE>>**

## Data Structure Questions and Answers-Factorial using Recursion

Congratulations - you have completed *Data Structure Questions and Answers-Factorial using Recursion*.

You scored %%SCORE%% out of %%TOTAL%%.

Your performance has been rated as %%RATING%%

Your answers are highlighted below.

Question 1 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Which of the following methods can be used to find the factorial of a number?

Recursion | |

Iteration | |

Dynamic programming | |

All of the mentioned |

Question 1 Explanation:

All of the above mentioned methods can be used to find the factorial of a number.

Question 2 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Which of the following recursive formula can be used to find the factorial of a number?

fact(n) = n * fact(n) | |

fact(n) = n * fact(n+1) | |

fact(n) = n * fact(n-1) | |

fact(n) = n * fact(1) |

Question 2 Explanation:

fact(n) = n * fact(n - 1) can be used to find the factorial of a number.

Question 3 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Consider the following iterative implementation to find the factorial of a number:

int main() { int n = 6, i; int fact = 1; for(i=1;i<=n;i++) .....; printf("%d", fact); return 0; }

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

fact = fact + i | |

fact = fact * i | |

i = i * fact | |

i = i + fact |

Question 3 Explanation:

The line "fact = fact * i" should be inserted to complete the above code.

Question 4 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

Consider the following recursive implementation to find the factorial of a number:

int fact(int n) { if(.....) return 1; return n * fact(n - 1); } int main() { int n = 5; int ans = fact(n); printf("%d", ans); return 0; }

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

n = 0 | |

n != 0 | |

n == 0 | |

n == 1 |

Question 4 Explanation:

The line "n == 0" should be inserted to complete the above code.

Note: "n == 1" cannot be used because it does not take care of the case when n = 0, i.e when we want to find the factorial of 0.

Question 5 [CLICK ON ANY CHOICE TO KNOW MCQ multiple objective type questions RIGHT ANSWER] |

What is the time complexity of the above recursive implementation to find the factorial of a number?

O(1) | |

O(n) | |

O(n ^{2}) | |

O(n ^{3}) |

Question 5 Explanation:

The time complexity of the above recursive implementation to find the factorial of a number is O(n).

Once you are finished, click the button below. Any items you have not completed will be marked incorrect.

There are 5 questions to complete.