Unformatted text preview: Introduction to Algorithms Massachusetts Institute of Technology Professors Shaﬁ Goldwasser and Silvio Micali December 2, 2003 6.046J/18.410J Handout 28 Problem Set 8
This problem set is due in recitation on Friday, December 5th. Reading: Chapters 30.130.2, 31.131.8. There are 4 problems. Each problem is to be done on a separate sheet (or sheets) of threehole punched paper. Mark the top of each sheet with your name, the course number, the problem number, your recitation section, the date, and the names of any students with whom you collaborated. Problem 81. Modular Operations For this problem, do not assume that arithmetic operations have cost. You may assume that the operations and may be done in time . On inputs of length , we deﬁne an algorithm to be polynomialtime if it runs in time for some constant . (a) Given and prime , give a polynomialtime algorithm that computes Note that the size of the input is . . (c) Given an integer , give a polynomialtime algorithm to determine if is a power, i.e. if there exists integers, such that can be written as . Hint: Use part (b). Problem 82. Chinese Remainder Theorem Given integers , where and are prime, there exists a 11 and onto mapping between and , which is quite useful. Let’s explore it. The mapping is . You may assume that the operations and may be done in time . (a) Give an algorithm to compute given . (b) Now, let us deﬁne the following multiplication operator: . Show that it is closed under . (c) Ben Bitdiddle designs a new multiplication unit, called the BDiddy, that multplies two numbers using the following algorithm: 1. Map and into pairs . 2. Compute . 3. Map back into . . Analyze the BDiddy’s runtime and compare it to standard multiplication over Which is better to use? ¦ % " ¨ % ¢ '&GH'&G0"£¡ X5 @ u£eUu£0X¢ ` tsXEr ¦¢
auE§#¢ ` tdys
H§y§#¢ ¦ 5 ¢ ¦5 gi f X A a¨ ` X c5 5 [email protected]y¦t0X¢Er X ¦ aux¨#¢ ¦w§v¨©¢ [email protected] ¦ (f 5 f ¢ gq g p ¦ 5 d#¢ i ¦ d5g #¢ f ` ¦td5ys
U§y§#¢ ¢ ¦5 ¦ 5 ¢5¦ 5 X gq f 5 g p f ¢(¦tdy
0§y§y§#¢ 5 gi f £d2X X ¤ Y£76¨ ` 5 ¨ (b) Given two integers, integer to . and , give a polynomialtime algorithm to ﬁnd the closest ) @FEDCB¨ A 4 ¦1 ¢ 320)£¡ ¦'&$('&$#"!¡ %"¨% ¢ ¦¤¢ §¥£¡ @%" I9%" I%" I¨% U&$QTH&$QS(RGQPH&G" ¦ ©¨¢ @ ¦q 5p ¢ c )5 c5 g g [email protected] ` [email protected] hf hf X ¦ ©¨¢ ¨ VW ¦ 5 &c [email protected] 955 7876¨ ¦ Rc gi hf 2 Handout 28: Problem Set 8 Problem 83. Snowball Throwing Several 6.046 students hold a team snowball throwing contest. Each student throws a snowball with a distance in the range from 0 to . Let be the set of distances thrown by males and be the set of distances thrown by females. You may assume that the distance thrown by each student is unique and is an integer. Deﬁne a team score to be the combination of one male and one female throw. algorithm to determine every possible team score, as well as how many teams Give an could achieve a particular score. This multiset of values is called a cartesian sum and is deﬁned as: and Problem 84. Comparing Polynomials Two single variable degree polynomials, and , with coefﬁcients from are said to be identical if for all . Suppose you want to determine if two degree polynomials, with coefﬁcients in are identical, where . However, you are not explicitly given or . Rather, you are given two black boxes, which on any input return and , respectively. Give an efﬁcient MonteCarlo algorithm to determine if and are identical. If , your algorithm should output the correct answer with probability 1. If , your algorithm should output the correct answer with probability at least . X e You may use the following fact: A degree nonzero polynomial has at most which it evaluates to 0. values of ¦¢ t0X{ m m {`m ¦t0X¢m e pf p f QX { m Y` { ¤ eb#)jyh©gfad ¦¦ ¢ i5 ¢ e9 ¦c X5 @ R(` eU(sX¢
. (d) Suppose you are given inputs and compute . You may assume that . Give an algorithm to w vtr m m e R}~[email protected] y g l u q trI 8p` s r qo n l e x )5 c5 d[email protected] )k R8¤ p p f vX f e ) !X ¦¢ ¦¢ tsX!y ` tsX!x ¦)%" ¢ UTRGF#)!¡ { {5 7zm for ...
View
Full Document
 Fall '01
 CharlesE.Leiserson
 Algorithms, Natural number, Prime number, TSx, Algorithms Massachusetts Institute of Technology Professors

Click to edit the document details