assignment1_sol

# assignment1_sol - CAS707 Assignment 1 Yixian Luo 0901958...

This preview shows pages 1–3. Sign up to view the full content.

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CAS707 Assignment 1 Yixian Luo 0901958 February 23, 2010 Part I Question 1 ∑ ( k | ≤ k ≤ N : a + bk ) = ( ∑ ( k | ≤ k ≤ N : a + bk ) + ∑ ( k | ≤ k ≤ N : a + bk )) / 2 = <using permutation: k:=N-k> ( ∑ ( k | ≤ k ≤ N : a + bk ) + ∑ ( k | ≤ N- k ≤ N : a + b ( N- k )) / 2 = < ≤ N- k ≤ N equals ≤ k ≤ N > ( ∑ ( k | ≤ k ≤ N : a + bk ) + ∑ ( k | ≤ k ≤ N : a + b ( N- k )) / 2 = <(8.23)Axiom, Distributivity> ∑ ( k | ≤ k ≤ N : ( a + bk ) + ( a + b ( N- k ))) /2 = ∑ ( k | ≤ k ≤ N : 2 a + bN ) / 2 = ((2 a + bN ) / 2) × ∑ ( k | ≤ k ≤ N : 1) = ( N + 1) × (2 a + bN ) / 2 Part II Question 2 We can represent this problem as follows: 1 { s = n 2 V t = n 3 } s,t,n :=? , ? ,n &? { s = n 2 V t = n 3 } { s = n 2 V t = n 3 } s,t,n :=? , ? ,n &? { s = n 2 V t = n 3 } (“&” represents one kind assignment operator) We need to calculate assignments to s and t. According to our normal program, we can assume that n increase L after the assignment. L is a constant, and L. We can rewrite the formula above as { s = n 2 V t = n 3 } s,t,n :=? , ? ,n + L { s = n 2 V t = n 3 } (q, p are variables) Assume s and t will become s0, t0 respectively after assignments, so s 0 = ( n + L ) 2 = n 2 + 2 n + L = s + 2 n + L t 0 = ( n + L ) 3 = n 3 + 3 Ln 2 + 3 L 2 + L 3 Therefore, the assignments is: s,t,n := s + 2 n + L,t + 3 Ls + 3 L 2 n + L,n + L Part III Question 3 1 Specify formally a program to determine whether corresponding elements of a and b are all re- lated by relation R. From this problem, we know that a, b are arrays with the same length. So we can formally specify this program as: { M ≥ } c :=? { c ⇐⇒ ( ∀ ( i | ≤ i < M : a [ i ] = b [ i ]) } 2 Develop the program specified in (1)....
View Full Document

## This note was uploaded on 03/31/2010 for the course CAS 707 taught by Professor Ridhakhedri during the Spring '10 term at McMaster University.

### Page1 / 8

assignment1_sol - CAS707 Assignment 1 Yixian Luo 0901958...

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

View Full Document
Ask a homework question - tutors are online