arxiv:1012.1336v2 [cs.cc] 8 Dec 2010

Similar documents
Running Time ( 3.1) Analysis of Algorithms. Experimental Studies ( 3.1.1) Limitations of Experiments. Pseudocode ( 3.1.2) Theoretical Analysis

1. MATHEMATICAL INDUCTION

Soving Recurrence Relations

3. Greatest Common Divisor - Least Common Multiple

Factoring x n 1: cyclotomic and Aurifeuillian polynomials Paul Garrett <garrett@math.umn.edu>

CS103X: Discrete Structures Homework 4 Solutions

Lesson 15 ANOVA (analysis of variance)

In nite Sequences. Dr. Philippe B. Laval Kennesaw State University. October 9, 2008

Lecture 4: Cauchy sequences, Bolzano-Weierstrass, and the Squeeze theorem

SAMPLE QUESTIONS FOR FINAL EXAM. (1) (2) (3) (4) Find the following using the definition of the Riemann integral: (2x + 1)dx


A probabilistic proof of a binomial identity

Asymptotic Growth of Functions

Sequences and Series

Factors of sums of powers of binomial coefficients

WHEN IS THE (CO)SINE OF A RATIONAL ANGLE EQUAL TO A RATIONAL NUMBER?

5 Boolean Decision Trees (February 11)

Convexity, Inequalities, and Norms

Department of Computer Science, University of Otago

Example 2 Find the square root of 0. The only square root of 0 is 0 (since 0 is not positive or negative, so those choices don t exist here).

1. C. The formula for the confidence interval for a population mean is: x t, which was

THE ARITHMETIC OF INTEGERS. - multiplication, exponentiation, division, addition, and subtraction

How To Solve The Homewor Problem Beautifully

Cooley-Tukey. Tukey FFT Algorithms. FFT Algorithms. Cooley

Properties of MLE: consistency, asymptotic normality. Fisher information.

Incremental calculation of weighted mean and variance

Infinite Sequences and Series

5.3. Generalized Permutations and Combinations

Repeating Decimals are decimal numbers that have number(s) after the decimal point that repeat in a pattern.

Hypothesis testing. Null and alternative hypotheses

Irreducible polynomials with consecutive zero coefficients

Chapter 6: Variance, the law of large numbers and the Monte-Carlo method

Section 11.3: The Integral Test

Chapter 5: Inner Product Spaces

Confidence Intervals for One Mean


Lecture 4: Cheeger s Inequality

Trigonometric Form of a Complex Number. The Complex Plane. axis. ( 2, 1) or 2 i FIGURE The absolute value of the complex number z a bi is

1 Computing the Standard Deviation of Sample Means

I. Chi-squared Distributions

CME 302: NUMERICAL LINEAR ALGEBRA FALL 2005/06 LECTURE 8

Lecture 13. Lecturer: Jonathan Kelner Scribe: Jonathan Pines (2009)

Fast Fourier Transform

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 13

Chapter 7 - Sampling Distributions. 1 Introduction. What is statistics? It consist of three major areas:

Notes on exponential generating functions and structures.

Lecture 2: Karger s Min Cut Algorithm

Theorems About Power Series

Integer Factorization Algorithms

5: Introduction to Estimation

.04. This means $1000 is multiplied by 1.02 five times, once for each of the remaining sixmonth

THE REGRESSION MODEL IN MATRIX FORM. For simple linear regression, meaning one predictor, the model is. for i = 1, 2, 3,, n

Modified Line Search Method for Global Optimization

Lecture 3. denote the orthogonal complement of S k. Then. 1 x S k. n. 2 x T Ax = ( ) λ x. with x = 1, we have. i = λ k x 2 = λ k.

CHAPTER 7: Central Limit Theorem: CLT for Averages (Means)

FIBONACCI NUMBERS: AN APPLICATION OF LINEAR ALGEBRA. 1. Powers of a matrix

Lecture 5: Span, linear independence, bases, and dimension

The Stable Marriage Problem

Determining the sample size

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

Chair for Network Architectures and Services Institute of Informatics TU München Prof. Carle. Network Security. Chapter 2 Basics

CS103A Handout 23 Winter 2002 February 22, 2002 Solving Recurrence Relations

The Power of Free Branching in a General Model of Backtracking and Dynamic Programming Algorithms

Math C067 Sampling Distributions

Basic Elements of Arithmetic Sequences and Series

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

Chapter 7 Methods of Finding Estimators

On Formula to Compute Primes. and the n th Prime

Taking DCOP to the Real World: Efficient Complete Solutions for Distributed Multi-Event Scheduling

Chapter 7: Confidence Interval and Sample Size

A Faster Clause-Shortening Algorithm for SAT with No Restriction on Clause Length

Section 8.3 : De Moivre s Theorem and Applications

Maximum Likelihood Estimators.

where: T = number of years of cash flow in investment's life n = the year in which the cash flow X n i = IRR = the internal rate of return

Z-TEST / Z-STATISTIC: used to test hypotheses about. µ when the population standard deviation is unknown

Week 3 Conditional probabilities, Bayes formula, WEEK 3 page 1 Expected value of a random variable

2-3 The Remainder and Factor Theorems

7.1 Finding Rational Solutions of Polynomial Equations

Permutations, the Parity Theorem, and Determinants

ON AN INTEGRAL OPERATOR WHICH PRESERVE THE UNIVALENCE

Perfect Packing Theorems and the Average-Case Behavior of Optimal and Online Bin Packing

FOUNDATIONS OF MATHEMATICS AND PRE-CALCULUS GRADE 10

CHAPTER 3 THE TIME VALUE OF MONEY

Our aim is to show that under reasonable assumptions a given 2π-periodic function f can be represented as convergent series

Output Analysis (2, Chapters 10 &11 Law)

BINOMIAL EXPANSIONS In this section. Some Examples. Obtaining the Coefficients

Approximating Area under a curve with rectangles. To find the area under a curve we approximate the area using rectangles and then use limits to find

Overview of some probability distributions.

THE LEAST COMMON MULTIPLE OF A QUADRATIC SEQUENCE

INFINITE SERIES KEITH CONRAD

MARTINGALES AND A BASIC APPLICATION

GCE Further Mathematics (6360) Further Pure Unit 2 (MFP2) Textbook. Version: 1.4

Project Deliverables. CS 361, Lecture 28. Outline. Project Deliverables. Administrative. Project Comments

S. Tanny MAT 344 Spring be the minimum number of moves required.

Multiple Representations for Pattern Exploration with the Graphing Calculator and Manipulatives

UC Berkeley Department of Electrical Engineering and Computer Science. EE 126: Probablity and Random Processes. Solutions 9 Spring 2006

A Mathematical Perspective on Gambling

Hypergeometric Distributions

A Note on Sums of Greatest (Least) Prime Factors

EGYPTIAN FRACTION EXPANSIONS FOR RATIONAL NUMBERS BETWEEN 0 AND 1 OBTAINED WITH ENGEL SERIES

Transcription:

Uary Subset-Sum is i Logspace arxiv:1012.1336v2 [cs.cc] 8 Dec 2010 1 Itroductio Daiel M. Kae December 9, 2010 I this paper we cosider the Uary Subset-Sum problem which is defied as follows: Give itegers m 1,...,m ad B (writte i uary), we defie the subset sum problem to be that of determiig whether or ot there exists a S [] so that i S m i = B (ote that for this problem the m i are ofte assumed to be o-egative). Let C = B + x i + 1. This problem ca be solved usig a stadard dyamic program usig space O(C) ad time O(C). The dyamic program makes fudametal use of this large space ad it is iterestig to ask whether this requiremet ca be removed. Uary Subset- Sum has bee studied i small-space models of computatio as early as 1980 i [4], where they showed that it was i NL. Sice the the problem was studied i [2], where Cho ad Huyh devised a complexity class betwee L ad NL that cotaied Uary Subset-Sum as supportig evidece that it is ot N L-complete. This problem was listed agai i [1] claimig it to be a ope problem as to whether or ot it is i L. It was recetly show i [3] that this problem was i Logspace. Ufortuately, their algorithm is somewhat complicated. We provide a simple algorithm solvig this problem i Logspace. 2 Our Algorithm The basic idea of our algorithm will be to make use of the geeratig fuctio (1+xmi ) = S [] x i S mi to compute the umber of solutios to our problem modulo p for a umber of differet primes p (we show how to do this i Lemma 1). Pseudocode for our algorithm is follows: 1

c := 0 p := NextPrime(C) While(c ) If x B ) 0 (mod p) (1+xmi Retur True c := c+ log 2 (p) p := NextPrime(p) Ed While Retur False 2.1 Space Complexity There are several thigs that must be oted to show that this algorithm rus i logspace. First we claim that p is ever more tha polyomial i size. This is because stadard facts about prime umbers imply that there are at least primes betwee C ad poly(c,), ad each of these primes causes c to icrease by at least 1. We also ote that x B (1 + xmi ) ca be computed modulo p i Logspace. This is because we ca just keep track of the value of x ad the curret ruig total (modulo p) alog with the space ecessary to compute the ext term. The product is computed agai by keepig track of i ad the curret ruig product (modulo p) ad whatever is ecessary to compute the ext term. The expoets are computed i the obvious way. Fially primality testig of poly-sized umbers ca be doe by repeated trial divisios i Logspace, ad hece the NextPrime fuctio ca also be computed i Logspace. 2.2 Correctess We ow have to prove correctess of the algorithm. Let A be the umber of subsets S [] so that i S m i = B. Lemma 1. For p a prime umber, p > C. The x B (1+x mi ) A (mod p). Where agai A is the umber of subsets S [] so that i S m i = B. Proof. Note that x B (1+x mi ) = x i S mi B. S [] The idea of our proof will be to iterchage the order of summatio ad show that the terms for which i S m i B cacel out. 2

Notice that each expoet i this sum has absolute value less tha p 1. Iterchagig the sums o the right had side, we fid that We ote that: x B (1+x mi ) = x i S mi B. x k (mod p) S [] { 1 if k 0 (mod ). 0 else If k is a multiple of p 1, the all terms i the sum are 1 modulo p ad the result follows. Otherwise, we let g be a primitive root mod p ad ote that istead of summig over x = 1 to p 1 we may sum over x = g l for l = 0 to p 2. The Hece p 2 x k l=0 g kl 1 gk() 1 g k x B (1+x mi ) = x i S mi B S [] 1 1 1 g k 0. S [] i S xi B (mod ) SiceislargerthaC, i S x i B (mod )ifadolyif i S x i = B. Hece this sum cotributes -1 for each such S ad so the fial sum is A. We are ow ready to prove correctess. If (1 + ) 0 xmi (mod p) for some p > C, the by our Lemma, this meas that A 0 (mod p). I particular, this meas that A 0, ad that therefore there is some such S. Cosider a iteger d which is equal to the product of the primes p that have bee checked so far. The d is a product of distict primes p so that A x B ) 0 (mod p). Therefore d A. Furthermore it (1+xmi is the case that d 2 c. It is clear from the defiitio of A that 0 A 2. Thereforeif c >, d > 2 ad d A, which implies that A = 0, ad that therefore there are o solutios. Hece our algorithm always outputs correctly. 3 Extesios x B There are some relatively simple extesios of this algorithm. For oe thig, our algorithm does more tha tell us whether or ot A is equal to 0, but also tells us cogruetial iformatio about A. We ca i fact obtai more refied cogruetial iformatio tha is apparet from our Lemma. We ca also use this alog with the Chiese Remaider Theorem to compute a umerical approximatio of A. Fially a slight geeralizatio of these techiques allows us to work with m i vector valued rather tha iteger-valued. 1. 3

3.1 Computig Cogrueces We show above how to compute A modulo p for p a prime larger tha C. But i fact if p is ay prime ad k > 1 ay iteger, A ca be computed modulo p k i O(log(p k )) space. If p > C, the we have that A 1 x B (1+x mi ) (mod p). O the other had if p C, the above expressio will oly cout the umber of subsets that give the correct sum modulo p 1. We ca fix this by lettig q = p l for some iteger l so that q > C. The for the same reasos that the above is true, it will be the case that A 1 q 1 x B (1+x mi ) (mod p). x F q Where F q is the fiite field of order q. If we have k > 1 ad p > C we ote that agai for the same reasos A 1 x µ x B (1+x mi ) (mod p k ). Where µ is the set of () st roots of uity i Z/p k. This computatio ca be performed without difficulty i Z/p k. We agai ru ito difficulty if p < C. We ca let r = ()p l for some iteger l so that r > C. It will the be the case that ra x B (1+x mi ) (mod p k+l ). x µ r The right had side ca easily be computed i Z/p k+l, ad dividig by r gives A (mod p k ). 3.2 Approximatig the Number of Solutios It is also possible i Logspace to approximate the umber of solutios, A, computig logarithmically may sigificat bits. This ca be doe usig the Chiese Remaider Theorem. Suppose that p 1,...,p k are distict primes. By the above we ca compute A modulo p i for each i. Let N = k p i, ad N i = N p i. The Chiese Remaider Theorem tells us that A k N i (A (mod p i )) ( N 1 i (mod p i ) ) (mod N). 4

Or i other words, A k ( 1 N p i ) (A (mod p i )) ( N 1 i (mod p i ) ) (mod 1). Now we ca compute A modulo p i by the above. We ca also compute N 1 i j i j (mod p i ). Hece we ca compute each term i the sum to logarithmically may bits. Hece i logspace we ca compute A N (mod 1) to logarithmically may bits of precisio. If 2A > N > A, this allows us to compute logarithmically may sigificat bits of A. We ca fid such a N by startig with a N > 2 A ad repeatedly tryig N at least half as big as the previous N util N < 2A (we ca fid our ext N by either removig the prime 2 from N or replacig the smallest prime dividig N by oe at least half as big (which exists by Bertrad s postulate)). It should also be oted that this ability to approximately cout solutios i Logspace allows us to approximately uiformly sample from the space of solutios i Radomized Logspace. This is doe by decidig whether or ot each elemet is i S oe-by-oe ad puttig it i with probability early equal to the proportio of the remaiig solutios that have that elemet i S. 3.3 Vector-Valued Iputs We cosider the slightly modified subset sum problem where ow m i ad B lie i Z k, ad agai we wish to determie whether or ot there exists ad S so that i S m i = B. If we let C be oe more tha the sum of the absolute values of the coefficiets of the m i plus the absolute values of the coefficiets of B, a slight modificatio of our algorithm allows us to solve this problem i O(klog(C)) space ad C O(k) time (i particular if k = O(1), this rus i O(log(C)) space ad C O(1) time). There are two ways to do this. Oe is simply to treat our vectors as base C-expasios of itegers ad reduce this to our previous algorithm. Aother techique ivolves a slight geeralizatio of our Lemma. I either case we let m i = (m i,1,...,m i,k ), B = (B 1,...,B k ). For the firstalgorithm, welet m i = k j=1 Cj 1 m i,j ad B = k j=1 Cj 1 B j. We claim that for ay S [] that i S m i = B if ad oly if i S m i = B, thus reducig this to a istace of our origial problem. The claim holds because m i B = i S k j=1c j 1( i S m i,j B j ) = k C j 1 e j. Sice the e j are all itegers of absolute value less tha C, this sum is 0 if ad oly if, each of the e j are 0. Hece i S m i = B if ad oly if i S m i = B. j=1 5

Aother way to do this is by geeralizig our Lemma. I particular it ca be show usig similar techiques that if A is the umber of subsets S that work, ad if p is a prime bigger tha C that A x 1,...,x k =1 ( k x Bi i ) 1+ k j=1 x mi,j j (mod p). Give this, there is a atural geeralizatio of our algorithm. It should also be oted that both of these techiques allow us to use the above-stated geeralizatios to our algorithm i the vector-valued cotext. This geeralizatio also allows us to solve some related problems, such as the Uary 0-1 Kapsack problem. This problem is defied as follows: You are give a list of iteger weights w 1,...,w, a list of iteger values, v 1,...,v, ad a iteger boud B. The objective is to fid a subset S [] so that i S v i is as large as possible subject to the restrictio that i S w i B. We do this by determiig all possible pairs of ( i S w i, i S v i) by applyig our algorithm to m i = (w i,v i ) ad B = (w,v) for all w w i, v v i. Of the pairs (w,v) for which there is a solutio, we keep track of the largest v that correspods to a w B. From this pair it is also ot hard to use our algorithm to fid a subset S which achieves this boud. Refereces [1] Alvarez, C. ad Greelaw, R. A Compedium of Problems Complete for Symmetric Logarithmic Space, Computatioal Complexity, Vol. 9(2), 2000. [2] S. Cho ad D. Huyh O a complexity hierarchy betwee L ad NL Iform. Process. Lett. 29, 1988, 177182. [3] Michael Elberfeld, Adreas Jakoby, Till Tatau Logspace Versios of the Theorems of Bodlaeder ad Courcelle, Foudatios of Computer Sciece, 2010. [4] B. Moie ad I. H. Sudborough Formal laguage theory I Formal Laguage Theory, ed. R. V. Book. Academic Press, 1980. 6