## Help authour, Buy PDF Ebook
>>>**Click Here**<<<

## Data Structure Questions and Answers-Factorial using Recursion

## Click on any option to know the CORRECT ANSWERS

Question 1 |

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

Recursion | |

Iteration | |

Dynamic programming | |

All of the mentioned |

**HRM Questions answers**

Question 1 Explanation:

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

Question 2 |

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) |

**Aptitude test Questions answers**

Question 2 Explanation:

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

Question 3 |

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 |

**English grammar Questions answers**

Question 3 Explanation:

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

Question 4 |

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 |

**Public administration Questions answers**

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 |

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}) |

**Reasoning Questions answers**

Question 5 Explanation:

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

There are 5 questions to complete.