



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




There are five problems each worth five points for a total of 25 points. Show all your work, partial credit will be awarded. Space is provided on the test for your work; if you use a blue book for additional workspace, sign it and return it with the test. No notes, no collaboration.
sum = 0 for i = 1 to length(A) sum = sum + A[i] end for
Write a loop invariant which shows that this code correctly calculates the sum of the values stored in A[1], A[2], ... A[n]. Prove correctness using the invariant.
13 16 14 15 1 8 7 3 9 10