Question: (c) Consider the following algorithm for computing the factorial of some integer n>=2 . procedure FACTORIAL (n) i=1 j=1 while j=j+1i=i**jiji=jj do
(c) Consider the following algorithm for computing the factorial of some integer
n>=2.\ procedure FACTORIAL
(n)\
i=1\
j=1\ while
j=j+1i=i**jiji=jj do\ j=j+1\ i=i**j\ end while\ return i\ end procedure\ (i) (8 points) To prove the correctness of this algorithm, the following loop invariant for the while loop in lines 4-7 can be defined:\ Loop Invariant: At the start of iteration j, it must be that i=j !\ Prove correctness by showing that this loop invariant is true using the initialization, maintenance, and termination properties.\ (ii) (2 points) Compute the worst-case running time.\ 2 
c) Consider the following algorithm for computing the factorial of some integer n2. procedure FACTORIAL (n) i=1 j=1 while j
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
