Fundamentals of Algorithms

Question #172

Read the question, compare the options, and review the correct answer below.

CS502 · Final-term only#172

Consider the following Algorithm:
Factorial (n){
if (n=1)
return 1
else
return (n * Factorial(n-1))
}
Recurrence for the following algorithm is:

  1. A
    ? T(n) = T(n-1) +1
  2. B
    ? T(n) = nT(n-1) +1
  3. C
    ? T(n)= T(n-1) +n
  4. D
    ? T(n)=T(n(n-1)) +1
Show correct answer

Correct answer: D. ? T(n)=T(n(n-1)) +1

Check community answers against your course notes.
← More practice questionsTake a timed test