CS
xxx_08s

# xxx_08s - MCS-265 David Wolfe Homework set 8(half set...

• Notes
• 1

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

MCS-265 Homework set 8 (half set) solution April 30, 2004 David Wolfe Due: May 4, 2004 1. Your goal is to familiarize yourself with Appendix A of the Garey & Johnson. 2. (Related to Sipser 7.12) Let MODEXP = {( a, b, c, p ) : 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 ( b ) . 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, b, c, p ) . (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:
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

• Spring '09
• Ib
• Remainder, Exponentiation, MCS-265 David Wolfe, eﬃcient recursive algorithm

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern