assignment 5

assignment 5 - CS-536 spring 2010 Assignment #5

Info iconThis preview shows pages 1–3. 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: CS-536 spring 2010 Assignment #5 -----------------------------------------------------------Due date – April 9th 2010 -----------------------------------------------------------Question 1. Prove total correctness using the lexicographic order for proving termination for the following GCD program {a>0 ^ b>0} (x,y) : (a,b) LOOPSELECT x> y => x:=x-y or y>x => y:=y-x end LOOPSELECT; GCD:=x {GCD = gcd(a,b) } Question 2. Given a two dimensional array B [0..R-1] [0.C-1] {R > 0 ^ C > 0} Program {N-of-zeros = Ni,j : 0 <= i <R, 0<=j < C ; B[i,j]=0} (The program counts how many zeros there are in a non empty matrix B [0..R-1] [0..C-1]) Construct the program using a non deterministic loopselect constrauct and prove total correctness. Question 3. Prove termination of the integer division program. Question 4. Prove total correctness of the following program {true} (A,B,C,D) = (a,b,c,d) Loopselect A>B => A:=A-1 Or B>C => B:=B-1 Or C>D =>C:=C-1 Or D>A => D:=D-1 End loopselect {A=B=C=D=min} where nin =minimum(a,b,c,d) Question 5. Prove total correctness {true} (A,B,C,D, E) := (a,b,c,d,e); Loopselect A> B => Swap ( Or B>C => Swap ( Or C>D => Swap ( ) ) ) Or D>E => Swap ( ) End loopselect {(A,B,C,D, E) permutation (a,b,c,d,e) and sorted (A,B,C,D,E) } ...
View Full Document

Page1 / 3

assignment 5 - CS-536 spring 2010 Assignment #5

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

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