CS336F09SExam 1

# CS336F09SExam 1 - b. wp(y:= x - y; x:= x + y, x y) = c....

This preview shows page 1. Sign up to view the full content.

Sample Exam 1 CS 336 General Instructions: Do all of your work on these pages. If you need more space, use the backs (to ensure the grader sees it, make a note of it on the front). Make sure your name appears on every page. Please write legibly and show your reasoning clearly. In your proofs, show a justification for each step. 1. Formalize the following English specification: Let b be an array of length n. Store in c reverse b. 2. Find x to make the following program segment correct. Check. {Q: 0<n} i ,z:= 1, x; {R: 0 i n z = ( j| 1 j<i : j)} 3. (Find the weakest precondition for the following: a. wp(“x, y := x + y, x - y”, x y) =
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: b. wp(y:= x - y; x:= x + y, x y) = c. wp(y:= x - y; x:= x + y, x y) wp(y:= x - y; x:= x + y, x > y) = d. wp( i,m:= 0, b[0], 0 i n ( j| 0 j<i: m=b[j])) = e. wp( t :=n-i; if b[i]=0 z:=z+1 & b[i] 0 skip fi, t > n-i-1) 4. For the following: {n>0} i,y:= n, a n {0 i n y= ( j| i j n: a j x j-i )} do i>0 i:= i-1; y:= y*x+a i od {y= ( j| 0 j n: a j x j )} a. Give a bound function for this loop. b. Prove that the invariant holds before the loop begins. c. Prove that the invariant holds after an iteration given it hold before....
View Full Document

## This note was uploaded on 11/30/2010 for the course CS 336 taught by Professor Myers during the Fall '08 term at University of Texas at Austin.

Ask a homework question - tutors are online