Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

CS70 Midterm 2 Solutions - Computing with Polynomials, Exams of Discrete Mathematics

The solutions to problem 3 of the cs70 midterm 2 exam, fall 2001. The problem deals with computing with polynomials, discussing the time complexity and algorithms for modular multiplication and addition.

Typology: Exams

2012/2013

Uploaded on 04/02/2013

sharda_852
sharda_852 🇮🇳

3

(2)

66 documents

1 / 2

Toggle sidebar

Related documents


Partial preview of the text

Download CS70 Midterm 2 Solutions - Computing with Polynomials and more Exams Discrete Mathematics in PDF only on Docsity! cs70, fall 2001 midterm 2 solutions professor wagner Problem #1 (18 pts.) Short-answer questions (a) C(n,i)/2^n (b) 0.3 <= Pr[E union F] <= 0.5. 0.3 occurs if E is a subset of F, and 0.5 occurs if E and F are disjoint. (c) 2002, since each such string is of the form [k]1[2000-k]0 (where the quantity in brackets indicates the number of times to repeat) for some k in {0, 1, ..., 2001}, and there are 2002 such k. (d) All of them, since 2z = n+1 = 1 (mod n), so z-inverse = 2 (mod n). (Alternate explanation: gcd((n+1)/2,n) = gcd((n+1)/2,(n-1)/2) = gcd(1,(n-1)/2)=1 by Euclidean algorithm, so gcd(z,n) = 1, so z has an inverse mod n.) Problem #2 (12 pts.) Digit sums Consider an arbitrary natural number n. Write n in decimal: n = Ak*10^k + ... + A1*10 + A0 Then f(n) = Ak^3 + ... + A1^3 + A0^3 [by defn of f] = Ak + ... + A1 + A0 = Ak*10^k + ... + A1+10 + A0 [since 10^j = 1 (mod 3) for all j] = n (mod 3) n was arbitrary, so this must hold for all natural numbers. Problem #3 (12 pts.) Computing with polynomials (a) O(d^2(lg p)^2) There are O(d^2) cross-terms, and each requires O((lg p)^2) work to do a modular multiplication and addition. (b) O(d(lg p)^2) Computing the sequence 1, u, u^2, ..., u^d mod p takes d multiplications, then multiplying by Ai mod p takes d+1 multiplications, plus d more additions. (c) 1. Let v = f(u) mod p using part (b). 2. Return v^2 mod p Takes O(d(lg p)^2 + (lg p)^2) = O(d(lg p)^2) time. cs70, midterm 2 solutions, fall 2001 cs70, fall 2001course, semester/year midterm 2 solutionsexam # professor wagnerprofessor (e.g., Professor J. Wawrzynek)1
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved