Let recursive algorithm F be defined as follows:
F(int n):if n=1 then return 1else 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 functionguaranteed to terminatefor all valid inputs?i.return F(n-2)+2ii.return F()*2iii.return F()*2
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here