Question: 2 Loop Invariant [ 1 0 points ] Consider the following code: ` ` ` procedure FunTest ( n ) x leftarrow 2 0
Loop Invariant points
Consider the following code:
procedure FunTestn
xleftarrow
for i from to n do
xleftarrowxi
return x
i points Give a loop invariant LI for the loop in the code.
ii points Prove the maintenance, ie prove that if your LI is true at the start of an iteration with leq i leq n it remains true at the start of the next iteration with i
iii points When the loop terminates, what is the value held in variable x Prove that this is implied by your LI
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
