exercise2-solved

# exercise2-solved - Algorithms and Data Structures...

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: Algorithms and Data Structures Assignment 2 - Solution Flavia Grosan, Vladislav Perelman, Dr. Andreas N¨uchter Fall 2009 Exercise 2.1 Using the algorithm presented in the slides, it can be inferred: gcd(27, 3) gcd(252, 105) gcd(147, 105) A := 27 A := 252 A := 147 B := 3 B := 105 B := 105 C := A % B = 0 C := A % B = 42 C := A % B = 42 A := B = 3 A := B = 105 A := B = 105 B := C = 0 (!) B := C = 42 B := C = 42 C := A % B = 21 C := A % B = 21 A := B = 42 A := B = 42 B := C = 21 B := C = 21 C := A % B = 0 C := A % B = 0 A := B = 21 A := B = 21 B := C = 0 (!) B := C = 0 (!) ⇒ gcd (27 , 3) = 3 ⇒ gcd (252 , 105) = 21 ⇒ gcd (147 , 105) = 21 1 Exercise 2.2 1. A n = n 2 − A n- 1 ( ◦ ) p (1) : A 1 = 1 p ( n ) : A n = n ( n +1) 2 Base case: n = 1 A 1 = 1 · 2 2 = 1 – which is p (1), true. Step case: Assume p ( k ) is true ∀ k ≥ 1. Prove that p ( k + 1) is true. p ( k ) : A k = k ( k +1) 2 p ( k + 1) : A k +1 = ( k +1)( k +2) 2 A k +1 ⊜ ( k + 1) 2 − A k = ( k + 1) 2 − k ( k +1)...
View Full Document

{[ snackBarMessage ]}

### Page1 / 3

exercise2-solved - Algorithms and Data Structures...

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

View Full Document
Ask a homework question - tutors are online