CS336F09SExam 1sol - Sample Exam 1CS 336 General Instructions Do all of your work on these pages If you need more space use the backs(to ensure the

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Sample Exam 1CS 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. ( ∀ j| 0 ≤ j<n: c[n-j-1]=b[j]) 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)} wp((“ i ,z:= 1, x ”, 0 ≤ i ≤ n ∧ z = ( ∏ j| 1 ≤ j<i : j)) =<wp :=> 0 ≤ 1 ≤ n ∧ x= ( ∏ j| 1 ≤ j<i1: j) ↔ <empty range> ≤ 1 ∧ 1 ≤ n ∧ x=1 ↔ <arith; ∧− simp > 1 ≤ n ∧ x=1 Now, since 0 < n (the Q) must imply 1 ≤ n ∧ x=1 (the wp (S,R)) and the only way this is true is if x is set to 1. Proof: Q → wp(“S”, R) ↔ < instantiation> 0 < n → wp((“ i ,z:= 1, 1 ”, 0 ≤ i ≤ n ∧ z = ( ∏ j| 1 ≤ j<i : j)) ↔ <wp :=> 0 < n → 0 ≤...
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.

Page1 / 3

CS336F09SExam 1sol - Sample Exam 1CS 336 General Instructions Do all of your work on these pages If you need more space use the backs(to ensure the

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online