Algorithms Theory, Solution for Assignment 2

Similar documents
The Selection Problem - Variable Size Decrease/Conquer (Practice with algorithm analysis)

MA 524 Homework 6 Solutions

For combinatorial problems we might need to generate all permutations, combinations, or subsets of a set.

Mu Sequences/Series Solutions National Convention 2014

PTAS for Bin-Packing

1 Onto functions and bijections Applications to Counting

This lecture and the next. Why Sorting? Sorting Algorithms so far. Why Sorting? (2) Selection Sort. Heap Sort. Heapsort

L5 Polynomial / Spline Curves

Transforms that are commonly used are separable

Assignment 5/MATH 247/Winter Due: Friday, February 19 in class (!) (answers will be posted right after class)

Chapter 9 Jordan Block Matrices

Homework 1: Solutions Sid Banerjee Problem 1: (Practice with Asymptotic Notation) ORIE 4520: Stochastics at Scale Fall 2015

{ }{ ( )} (, ) = ( ) ( ) ( ) Chapter 14 Exercises in Sampling Theory. Exercise 1 (Simple random sampling): Solution:

AN UPPER BOUND FOR THE PERMANENT VERSUS DETERMINANT PROBLEM BRUNO GRENET

means the first term, a2 means the term, etc. Infinite Sequences: follow the same pattern forever.

1. A real number x is represented approximately by , and we are told that the relative error is 0.1 %. What is x? Note: There are two answers.

Third handout: On the Gini Index

Taylor s Series and Interpolation. Interpolation & Curve-fitting. CIS Interpolation. Basic Scenario. Taylor Series interpolates at a specific

Multiple Choice Test. Chapter Adequacy of Models for Regression

ρ < 1 be five real numbers. The

A tighter lower bound on the circuit size of the hardest Boolean functions

Exercises for Square-Congruence Modulo n ver 11

Class 13,14 June 17, 19, 2015

Log1 Contest Round 2 Theta Complex Numbers. 4 points each. 5 points each

Lecture 9: Tolerant Testing

Hard Core Predicates: How to encrypt? Recap

Derivation of 3-Point Block Method Formula for Solving First Order Stiff Ordinary Differential Equations

Lattices. Mathematical background

Analysis of Lagrange Interpolation Formula

Introduction to Probability

Laboratory I.10 It All Adds Up

MATH 247/Winter Notes on the adjoint and on normal operators.

Cubic Nonpolynomial Spline Approach to the Solution of a Second Order Two-Point Boundary Value Problem

Lecture 07: Poles and Zeros

8.1 Hashing Algorithms

Randomized Quicksort and the Entropy of the Random Number Generator

Pseudo-random Functions

QR Factorization and Singular Value Decomposition COS 323

MA/CSSE 473 Day 27. Dynamic programming

Investigation of Partially Conditional RP Model with Response Error. Ed Stanek

A Primer on Summation Notation George H Olson, Ph. D. Doctoral Program in Educational Leadership Appalachian State University Spring 2010

Pseudo-random Functions. PRG vs PRF

k 1 in the worst case, and ( k 1) / 2 in the average case The O-notation was apparently The o-notation was apparently

Random Variables and Probability Distributions

16 Homework lecture 16

Lecture 3 Probability review (cont d)

The Mathematical Appendix

Rademacher Complexity. Examples

Ideal multigrades with trigonometric coefficients

5 Short Proofs of Simplified Stirling s Approximation

9 U-STATISTICS. Eh =(m!) 1 Eh(X (1),..., X (m ) ) i.i.d

A unified matrix representation for degree reduction of Bézier curves

Answer key to problem set # 2 ECON 342 J. Marcelo Ochoa Spring, 2009

Algorithms Design & Analysis. Hash Tables

Chapter 4 Multiple Random Variables

Decomposition of Hadamard Matrices

UNIVERSITY OF OSLO DEPARTMENT OF ECONOMICS

Non-uniform Turán-type problems

Neville Robbins Mathematics Department, San Francisco State University, San Francisco, CA (Submitted August 2002-Final Revision December 2002)

Discrete Mathematics and Probability Theory Fall 2016 Seshia and Walrand DIS 10b

Runtime analysis RLS on OneMax. Heuristic Optimization

B-spline curves. 1. Properties of the B-spline curve. control of the curve shape as opposed to global control by using a special set of blending

CHAPTER 3 POSTERIOR DISTRIBUTIONS

2006 Jamie Trahan, Autar Kaw, Kevin Martin University of South Florida United States of America

Evaluating Polynomials

Solution of General Dual Fuzzy Linear Systems. Using ABS Algorithm

18.413: Error Correcting Codes Lab March 2, Lecture 8

Lecture 12 APPROXIMATION OF FIRST ORDER DERIVATIVES

UNIT 2 SOLUTION OF ALGEBRAIC AND TRANSCENDENTAL EQUATIONS

Polynomial Encryption Using The Subset Problem Based On Elgamal. Raipur, Chhattisgarh , India. Raipur, Chhattisgarh , India.

We have already referred to a certain reaction, which takes place at high temperature after rich combustion.

. The set of these sums. be a partition of [ ab, ]. Consider the sum f( x) f( x 1)

X X X E[ ] E X E X. is the ()m n where the ( i,)th. j element is the mean of the ( i,)th., then

Econometric Methods. Review of Estimation

Chapter 5 Properties of a Random Sample

Chapter 4 (Part 1): Non-Parametric Classification (Sections ) Pattern Classification 4.3) Announcements

CHAPTER VI Statistical Analysis of Experimental Data

1 Solution to Problem 6.40

Q-analogue of a Linear Transformation Preserving Log-concavity

Numerical Analysis Formulae Booklet

Lecture 16: Backpropogation Algorithm Neural Networks with smooth activation functions

Part 4b Asymptotic Results for MRR2 using PRESS. Recall that the PRESS statistic is a special type of cross validation procedure (see Allen (1971))

Descriptive Statistics

Lecture Notes Types of economic variables

The Primitive Idempotents in

Lecture 3. Sampling, sampling distributions, and parameter estimation

7.0 Equality Contraints: Lagrange Multipliers

THE ROYAL STATISTICAL SOCIETY GRADUATE DIPLOMA

Complete Convergence and Some Maximal Inequalities for Weighted Sums of Random Variables

( ) 2 2. Multi-Layer Refraction Problem Rafael Espericueta, Bakersfield College, November, 2006

ANALYSIS ON THE NATURE OF THE BASIC EQUATIONS IN SYNERGETIC INTER-REPRESENTATION NETWORK

Feature Selection: Part 2. 1 Greedy Algorithms (continued from the last lecture)

Analyzing Control Structures

Solutions to problem set ); (, ) (

Admissible Permutations and the HCP, the AP and the TSP

L(θ X) s 0 (1 θ 0) m s. (s/m) s (1 s/m) m s

Lecture 1. (Part II) The number of ways of partitioning n distinct objects into k distinct groups containing n 1,

Chapter 2 - Free Vibration of Multi-Degree-of-Freedom Systems - II

CS286.2 Lecture 4: Dinur s Proof of the PCP Theorem

Graphs and graph models-graph terminology and special types of graphs-representing graphs and graph isomorphism -connectivity-euler and Hamilton

Transcription:

Juor-Prof. Dr. Robert Elsässer, Marco Muñz, Phllp Hedegger WS 2009/200 Algorthms Theory, Soluto for Assgmet 2 http://lak.formatk.u-freburg.de/lak_teachg/ws09_0/algo090.php Exercse 2. - Fast Fourer Trasform The two polyomals have degree less tha 2, hece the polyomal pq has degree less tha 4. We represet p ad q by four etres a array ad compute DFT 4 usg FFT. We splt p a ad q a to two parts: For k 3, t holds that: p(x) = 3x + p a = [, 3, 0, 0] q(x) = 7x + 4 q a = [4, 7, 0, 0] p a = [, 0] p 2 a = [3, 0] q a = [4, 0] q 2 a = [7, 0] DF T k (p a, 4) = (DF T (p a, 2), DF T (p a, 2)) k + ω k 4 (DF T (p 2 a, 2), DF T (p 2 a, 2)) k () Ht: If v s a vector wth elemets ad v 2 s a vector wth m elemets, the (v, v 2 ) s a vector wth + m elemets, The: { v k f k (v, v 2 ) k := f < k + m ad j = k v j Example The followg example demostrates the otato gve above: ((, 2, 3), (4, 5)) = (, 2, 3, 4, 5) Hece, (DF T (p a, 2), DF T (p a, 2)) s a vector wth 4 etres, ad the frst two etres are the same as the secod oe. We state ω 0 4 = ω 2 4 = ω 4 = ω 3 4 = Hece we ca wrte DF T (p a, 4) = F F T (p a, 4) as: F F T (p a, 4) = (F F T ([, 0], 2) + F F T ([3, 0], 2), F F T ([, 0], 2) 2 + F F T ([3, 0], 2) 2, F F T ([, 0], 2) + ( ) F F T ([3, 0], 2), F F T ([, 0], 2) 2 + ( ) F F T ([3, 0], 2) 2 ) Now we have to compute F F T ([, 0], 2) ad F F T ([3, 0], 2).. Frst we compute F F T ([, 0], 2). It s defed as: F F T ([, 0], 2) = ((F F T ([], ), F F T ([], )) + (F F T ([0], ), F F T ([0], )), (F F T ([], ), F F T ([], )) 2 + ( ) (F F T ([0], ), F F T ([0], )) 2 ) = ( + 0, 0) = (, )

2. Now, F F T ([3, 0], 2) yelds: F F T ([3, 0], 2) = (3, 3) We opta F F T (p a, 4) = ( + 3, + 3, 3, 3) = (4, + 3, 2, 3) (2) For q a t holds that: F F T (q a, 4) = (F F T ([4, 0], 2) + F F T ([7, 0], 2), F F T ([4, 0], 2) 2 + F F T ([7, 0], 2) 2, F F T ([4, 0], 2) + ( ) F F T ([7, 0], 2), F F T ([4, 0], 2) 2 + ( ) F F T ([7, 0], 2) 2 ). Frst we compute F F T ([4, 0], 2). F F T ([4, 0], 2) = (4, 4) 2. Now, F F T ([7, 0], 2) yelds: F F T ([7, 0], 2) = (7, 7) The, F F T (q a, 4) = (4 + 7, 4 + 7, 4 7, 4 7) = (, 4 + 7, 3, 4 7) (3) Hece we get the result for p q by multplyg (2) ad (3) : Ths yelds F F T (p q, 4) = (4, ( + 3) (4 + 7), 2 ( 3), ( 3) (4 7)) = (44, 7 + 9, 6, 7 9) pq(ω 0 4) = pq() = 44 pq(ω 4) = pq() = 7 + 9 pq(ω 2 4) = pq( ) = 6 pq(ω 3 4) = pq( ) = 7 9 Hece we have a pot-value represetato of pq. Iterpolato To compute the coeffcets we set r(x) := [44, 7 + 9, 6, 7 9]. We compute FFT(r,4) by frst splttg r to two parts: r = [44, 6] ad r 2 = [ 7 + 9, 7 9]. F F T (r, 4) = (F F T ([44, 6], 2) + F F T ([ 7 + 9, 7 9], 2), F F T ([44, 6], 2) 2 + F F T ([ 7 + 9, 7 9], 2) 2, F F T ([44, 6], 2) F F T ([ 7 + 9, 7 9], 2), F F T ([44, 6], 2) 2 F F T ([ 7 + 9, 7 9], 2) 2 ) We compute FFT([44,6],2) ad FFT([-7 + 9, -7-9],2): F F T ([44, 6], 2) = (44 + 6, 44 6) = (50, 38) F F T ([ 7 + 9, 7 9], 2) = ( 34, 38) Hece: F F T (r, 4) = (50 34, 38 + 38 2, 50 + 34, 38 38 2 ) = (6, 0, 84, 76) 2

From ths we obta the coeffcets a 0 = 4 6 = 4 a = 76 = 9 4 a 2 = 4 84 = 2 a 3 = 4 0 = 0 ad hece pq = 0x 3 + 2x 2 + 9x + 4 Exercse 2.2 - FFT. Defe p A = a m x m + a x + a 0 p B = b m x m + b x + b 0 for 0 j m where { f j A a j = 0 f j / A b j = { f j B 0 f j / B The polyomal p C = p A p B = k 2m 2 x 2m 2 + k x + k 0 represets the set C = A + B. For 0 j 2m t holds that j C k j > 0 Sce p c ca be computed by FFT tme O(m log m), the statemet holds. 2. The umbers k j are the soluto for the secod questo. Please otce that t s mportat to choose a j = f j A ad b j = f j B. 3. I ths part we eed to cout for all x all pars (a, b) A B, such that there exsts a c N wth x = c (a + b). Frst assume we have a fxed x. Assume for example x = 6. Computg d 6 ca by doe by summg up k, k 2, k 3 ad k 6. For x = 8 we sum up k, k 2, k 4, k 8. More geerally, for each x {,..., 2m 2}: We ca wrte ths to a table: d x = 2m 2 =, x d = k d 2 = k +k 2 d 3 = k +k 3 d 4 = k +k 2 +k 4 d 5 = k +k 5 d 6 = k +k 2 +k 3 +k 6 k It s easy to see that k s part of each sum, whle k 2 s part of d 2, d 4, d 6,..., d 2m 2. geeral, for each {,..., 2m 2} the value k s part of d, d 2, d 3,..., d k, where I k 2m 2 < r(k + ) Our algorthm takes k j as put. It computes for each x {,..., 2m 2} the umber d x. 3

INPUT: k [ ] d [ ] = ew Array [.. 2m 2 ] ( 0 ) ; for each [.. 2m 2] do for (x = ; x+ = ; x < 2m 2) d [ x ] = d [ x ] + k [ ] OUTPUT: d [ ] For = 2m 2, the rutme of the algorthm T (m) s bouded by: T (m) = = Hece, the rutme s O(m log m). ( x= ) ( ) = = = ( + Exercse 2.3 - Radomzed Qucksort =2 ) ( + log ) O( log ). T () = Θ( 2 ) arses whe the worst-case parttog occurs (.d. parttog yelds two sub-problems, wth umber of elemets ad 0 respectvely). Possble permutatos π of ad probabltes for p l ad p r are: π =, 2,..., m ad p l = 0, p r =. Symmetrcally we have: π = m, m,..., ad p l =, p r = 0. π =, 2,..., m ad p l = 0.5, p r = 0.5. Oe possble executo of Radomzed Qucksort could lead to the followg parttos: 2. We prove that T () O( log ). left rght 2, 3,..., m pvot = l = 2, 3..., m pvot = r = m 3,..., m pvot = l = 2. We choose a costat c, such that {,..., } T () c log. ad we prove for large that T () c log. 4

The defto of Θ() ad T () states that for some c N: T () 2 T (k) + c = 2c k= 2 c k log k + c k= /2 k log k + k= Sce log s a mootoe creasg fucto = 2c /2 k log 2 + = c k= k=/2+ k=/2+ k log k + c k log + c We use log /2 = log log 2 ad log 2 2c /2 (log ) k + log k + c k= k=/2+ = 2c /2 log k k + c k= k= = 2c ( ( )( 2) (/2 )(/2 2) log 2 2 (log ( )( 2) 4 ) ( 2)( 4) + c c log c 4 (2 6 + 8) + c = c log c 4 + 3 2 c 2c + c c log c 4 + 3 2 c + c We choose c = 4 ( ) c + 3 2 ) + c c log c + c 3 2 + 3 2 c For large t holds > c, whch yelds 3 2 c 3 2. Exercse 2.4 - RSA c log. Gve, p = 9, q = 29 ad e = 5. Compute = pq = 55. Use the exteded Eucld algorthm wth a = (p )(q ) = 504 ad b = e = 5 to compute d as the multplcatve verse of e modulo (p )(q ). put output (504, 5) (,, 504 5 ) = (,, 0) (5, 4) (,, 0 5 4 ) = (,, ) (4, ) (, 0, 4 0) = (, 0, ) (, 0) (,, 0) 5

The exteded Eucld algorthm returs the modular multplcatve verses such that gcd(a, b) = ax + by = 504 ( ) + 5 (0) Sce d e mod 504 =, we have d = y = 0. Publc key P = (e, ) = (5, 55), secret key S = (d, ) = (0, 55). 2. P (M) = P (22) = 22 5 mod 55 = 29 6