0

Hoare Triple formalizes program correctness, which contains postcondition, program and precondition such as $\vdash P \{Q\} R$

Provided code snippet:

i := 0;
s := 0;
while i < N do
   s := s + max(arr[i]);
   i := i + 1;
od

The program's goal is to compute the sum of the maximum integers obtained from each element $arr[i]$, for $0 ≤ i < N$.

What is a proper Hoare Triple and loop invariant for this program? I’m stuck with prove of partial correctness because of loop invariant.

Bruce
  • 1
  • 1

0 Answers0