Math 470.502 Communications & Cryptography HW #3 September 19, 2014

advertisement
Math 470.502
Communications & Cryptography
HW #3
September 19, 2014
Due Friday, September 26.
A. In this problem we will analyze the efficiency of the Euclidean Algorithm. Here is a
recap of the algorithm as we discussed in class.
Euclidean Algorithm. Let a, b be positive integers with a ≥ b. The following
algorithm computes gcd(a, b) in a finite number of steps.
(i) Let r0 = a and r1 = b.
(ii) Set i = 1.
(iii) Divide ri−1 by ri to obtain quotient qi and remainder ri+1 :
ri−1 = ri · qi + ri+1 ,
0 ≤ ri+1 < ri .
(iv) If ri+1 = 0, then gcd(a, b) = ri and the algorithm terminates.
(v) Otherwise ri+1 > 0, so set i := i + 1 and go to step (iii).
We discussed in class how and why this algorithm works (and terminates!). The purpose here is to determine a maximum number of iterations of the loop needed until it
terminates. Answer the following questions.
(a) Show for all i = 0, 1, 2, . . . that
1
ri+2 < ri ,
2
by examining the following cases:
• Case 1: Assuming ri+1 ≤ 12 ri , show that ri+2 < 12 ri .
• Case 2: Assuming ri+1 > 12 ri , show that ri+2 < 12 ri . (Hint: when we write
ri = ri+1 · qi+1 + ri+2 via the division algorithm, what must qi+1 be?)
(b) Use part (a) to show that, for any k ≥ 0,
r2k+1 <
b
.
2k
(c) Now let k be the smallest integer such that 2k ≥ b > 2k−1 . Show that k < log2 (b)+
1. Show that the maximum number of steps through the loop is 2k < 2 log2 (b)+2.
Thus the Euclidean algorithm requires at most d2 log2 (b) + 1e iterations.
Download