Question: 1- How many bytes of stack space would be used by the Factorial procedure when calculating 7 !? 2- The recursive factorial algorithm can be

1- How many bytes of stack space would be used by the Factorial procedure when calculating 7 !?

2- The recursive factorial algorithm can be shown in C/C++/Java syntax as follows:

int factorial (int n) // line 1

{ // line 2

if (n == 0) // line 3

return 1; // line 4

else // line 5

return n * factorial(n-1); // line 6

} // line 7

Assume we call this function to calculate 5!. Please draw the runtime stack frames when line 4 is being executed (cf. page 293 for the assembly code, in which the instruction corresponding to line 4 is move eax, 1, page 294).

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!