Question: The following code is supposed to return n!, for positive n. An analysis of the code using our Three Question approach reveals that: int factorial

The following code is supposed to return n!, for positive n. An analysis of the code using our "Three Question" approach reveals that:

int factorial (int n){

if (n > 0)

return (n * factorial(n - 1));

}

A)

it fails the base-case question.

B)

it fails the smaller-caller question.

C)

it fails the general-case question.

D)

it passes on all three questions and is a valid algorithm.

E)

None of these is correct.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!