{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw_0_soln - CS 473 Algorithms Fall 2010 HW 0(due Tuesday...

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

CS 473: Algorithms, Fall 2010 HW 0 (due Tuesday, August 31st in class) This homework contains four problems. Read the instructions for submitting homework on the course webpage . In particular, make sure that you write the solutions for the problems on separate sheets of paper. Write your name and netid on each sheet. Collaboration Policy: For this home work, each student should work independently and write up their own solutions and submit them. Read the course policies before starting the homework. Problems 1-3 should be answered in Compass as part of the assessment HW0-Online. Note: Before starting to answer the questions on compass, read the following recaps: lg n = log 2 n and ln n = log e n . lg 2 n = (lg n ) 2 and lg lg n = lg(lg n ). H n is the n ’th harmonic number and H n = n i =1 1 /i ln n + 0 . 577215 . . . . F n is the n ’th Fibonacci number and satisfies the recurrence F n = F n - 1 + F n - 2 with F 0 = 0 , F 1 = 1. It can be verified by induction (try it!) that F n = ( φ n - ( - 1 ) n ) / 5 where φ = (1 + 5) / 2 is the golden ratio. 1. (10pts) True/False questions on background. 2. (25pts) Asymptotics. 3. (25 pts) Basic recurrences. 4. (40pts) Euclid’s algorithm for finding the greatest common divisor (gcd) of two non-negative numbers a, b is the following. Algorithm Euclid ( a, b ): 1: If ( b = 0) 2: return a 3: Else 4: return Euclid ( b, a mod b ) Prove via induction that the algorithm correctly computes the gcd of a, b . Also prove that the running time of the algorithm is polynomial in the input size. Note that the input size is Θ(log a + log b ). Assume that the mod operation along with other basic arithmetic operations take constant time. Hint: For both parts think about how a + b is changing in each recursive call. A slow version of the Euclid algorithm is the following.

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.

{[ snackBarMessage ]}

### Page1 / 4

hw_0_soln - CS 473 Algorithms Fall 2010 HW 0(due Tuesday...

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

View Full Document
Ask a homework question - tutors are online