Question: 3 . Parts ( a ) and ( b ) refer to the following program. 1 . / / pre: M > = 0 2
Parts a and b refer to the following program.
pre: M
j
S
LoopInv:
whilej M:
SS jj
jj
post: S MMMMMM
a marks State and prove a loop invariant for this program. Hint: the variable S is
named for sum You will need to find a relationship between S and j that holds at
every check of the loop condition.
b marks Using the fact that your proposed statement in part a is a loop invariant,
prove that this program has the partial correctness property. Your proof of partial cor
rectness must not refer to any lines of code except for lines and
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
