Find the loop invariant of the given while loop
-
05-11-2019 - |
Question
I don't know how to find a loop invariant. I'm not sure where to start. Can anyone find the loop invariant of the given program and explain your method please.
{n ≥ 0 ∧ i = 0}
while i < n − 1 loop
b[i] := a[i + 1];
i:=i + 1
end loop
{∀j.(0 ≤ j < n − 1 → b[j] = a[j + 1])}
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with cs.stackexchange