Let recursive algorithm F be defined as follows: F(int n): if n=1 then return 1 else return F(n-1)*n (a) i. Assuming x is a positive integer, what mathematical expression is returned by F(x)? ii....



Let recursive algorithm F be defined as follows:



F(int n):
if n=1 then
    return 1
else
   return F(n-1)*n



(a) i. Assuming x is a positive integer, what mathematical expression is returned by F(x)?
ii. Repeat (i) but assume the line
“return 1”
is replaced by
“return 0”?



(b) Which of the following replacements for the last line will yield a function
guaranteed to terminate
for all valid inputs?

i.
return F(n-2)+2

ii.
return F(



)*2



iii.
return F(



)*2



Jun 09, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here