Question: ( 5 marks ) Select a loop invariant and give a complete proof tableau ( that is , add all the intermediate assertions ) for

(5 marks) Select a loop invariant and give a complete proof tableau (that is, add all the intermediate assertions) for the following correctness statement. Also make an argument for termination. The value k is constant integer and all variables are of type integer.
ASSERT(k0)
{ i=1;
sum =1;
while (i k){sum=sum+2*i+1;
i=i+1; }//end-while
}
ASSERT(sum==(k+1)*(k+1))
 (5 marks) Select a loop invariant and give a complete proof

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!