{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

pset8

# pset8 - Introduction to Algorithms Massachusetts Institute...

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

This is the end of the preview. Sign up to access the rest of the document.

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.1-30.2, 31.1-31.8. There are 4 problems. Each problem is to be done on a separate sheet (or sheets) of three-hole 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 8-1. 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 polynomial-time if it runs in time for some constant . (a) Given and prime , give a polynomial-time algorithm that computes Note that the size of the input is . . (c) Given an integer , give a polynomial-time algorithm to determine if is a power, i.e. if there exists integers, such that can be written as . Hint: Use part (b). Problem 8-2. Chinese Remainder Theorem Given integers , where and are prime, there exists a 1-1 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 B-Diddy, that multplies two numbers using the following algorithm: 1. Map and into pairs . 2. Compute . 3. Map back into . . Analyze the B-Diddy’s runtime and compare it to standard multiplication over Which is better to use? ¦ % " ¨ % ¢ '&GH'&G0"£¡    X5 @    u£eUu£0X¢ ` tsXEr ¦¢   auE§#¢ ` tdysH§y§#¢ ¦ 5 ¢  ¦5 gi f X A a¨ ` X c5 5 [email protected]y¦t0X¢Er X ¦  aux¨#¢ ¦w§v¨©¢   [email protected] ¦ (f 5 f ¢ gq g p ¦ 5 d#¢ i  ¦ d5g #¢ 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 polynomial-time algorithm to ﬁnd the closest ) @FEDCB¨ A 4 ¦1 ¢ 320)£¡ ¦'&\$('&\$#"!¡ %"¨% ¢ ¦¤¢ §¥£¡ @%" I9%" I%" I¨% U&\$QTH&\$QS(RGQPH&G" ¦    ©¨¢ @ ¦q 5p ¢ c )5 c5 g g [email protected] ` [email protected] hf hf X ¦ ©¨¢ ¨ VW ¦   5 &c [email protected] 955 7876¨ ¦ Rc gi hf 2 Handout 28: Problem Set 8 Problem 8-3. 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 multi-set of values is called a cartesian sum and is deﬁned as: and Problem 8-4. 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 Monte-Carlo 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- non-zero 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©gfad ¦¦ ¢ 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 ¦)%" ¢ UTRGF#)!¡ { {5 7zm for ...
View Full Document

{[ snackBarMessage ]}