{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

xxx_08s - x y x mod p y mod p(mod p xy x mod p y mod...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
MCS-265 Homework set 8 (half set) solution April 30, 2004 David Wolfe Due: May 4, 2004 2. (Related to Sipser 7.12) Let MODEXP = {a a, b, c, p A : a , b , c and p are binary integers such that a b c (mod p ) } We wish to show that MODEXP P . (a) Explain why the following reasoning is fallacious: An algorithm can compute a b in b 1 multiplications, take the result modulo p using one integer division, and then check if the result is equal to c . The reasoning is fallacious since b 1 multiplications takes time O (2 l ), where l is the length of a b A . Recall that since b is written with l = lg b bits, and hence b = 2 l . So this algorithm takes exponential time in the length of the input a a, b, c, p A . (b) Give an algorithm proving MODEXP P . Hint: You’ve seen the technique before in MCS-177. You’ll need to recall the following facts about mods:
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: x + y ≡ ( x mod p ) + ( y mod p ) (mod p ) xy ≡ ( x mod p )( y mod p ) (mod p ) Use repeated squaring or the eFcient recursive algorithm you learned in MC-27. One such eFcient scheme program would be: (define modexp (lambda (a b c p) (define modexp (lambda (a b) (modulo (cond ((= b 0) 1) ((even? b) (square (modexp a (/ b 2)))) ((odd? b) (* a (modexp a (- b 1))))) p))) (= (modexp a b) (modulo c p)))) At least every other call is with an even b (since any recursive call with odd b is followed by one with even b .) Hence, each such call shortens b by one bit, and O ( n ) recursive calls are required. Each call does a constant number of O ( n )-bit integer arithmetic operations, and so the procedure takes polynomial time....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online