Various Techniques. 1 Subset Sum problem. 1.1 Introduction. 1.2 k-sum problem

Similar documents
The Greedy Method. Introduction. 0/1 Knapsack Problem

Luby s Alg. for Maximal Independent Sets using Pairwise Independence

8.5 UNITARY AND HERMITIAN MATRICES. The conjugate transpose of a complex matrix A, denoted by A*, is given by

1 Example 1: Axis-aligned rectangles

Recurrence. 1 Definitions and main statements

n + d + q = 24 and.05n +.1d +.25q = 2 { n + d + q = 24 (3) n + 2d + 5q = 40 (2)

Generalizing the degree sequence problem

This circuit than can be reduced to a planar circuit

Project Networks With Mixed-Time Constraints

Ring structure of splines on triangulations

Lecture 2: Single Layer Perceptrons Kevin Swingler

What is Candidate Sampling

1. Fundamentals of probability theory 2. Emergence of communication traffic 3. Stochastic & Markovian Processes (SP & MP)

Simple Interest Loans (Section 5.1) :

We are now ready to answer the question: What are the possible cardinalities for finite fields?

Feature selection for intrusion detection. Slobodan Petrović NISlab, Gjøvik University College

Module 2 LOSSLESS IMAGE COMPRESSION SYSTEMS. Version 2 ECE IIT, Kharagpur

Institute of Informatics, Faculty of Business and Management, Brno University of Technology,Czech Republic

The Development of Web Log Mining Based on Improve-K-Means Clustering Analysis

Linear Circuits Analysis. Superposition, Thevenin /Norton Equivalent circuits

Level Annuities with Payments Less Frequent than Each Interest Period

Finite Math Chapter 10: Study Guide and Solution to Problems

8 Algorithm for Binary Searching in Trees

Implementation of Deutsch's Algorithm Using Mathcad

Logical Development Of Vogel s Approximation Method (LD-VAM): An Approach To Find Basic Feasible Solution Of Transportation Problem

Rate Monotonic (RM) Disadvantages of cyclic. TDDB47 Real Time Systems. Lecture 2: RM & EDF. Priority-based scheduling. States of a process

benefit is 2, paid if the policyholder dies within the year, and probability of death within the year is ).

SPEE Recommended Evaluation Practice #6 Definition of Decline Curve Parameters Background:

Forecasting the Direction and Strength of Stock Market Movement

1. Measuring association using correlation and regression

Calculation of Sampling Weights

POLYSA: A Polynomial Algorithm for Non-binary Constraint Satisfaction Problems with and

The Mathematical Derivation of Least Squares

To Fill or not to Fill: The Gas Station Problem

DEFINING %COMPLETE IN MICROSOFT PROJECT

Fisher Markets and Convex Programs

An Alternative Way to Measure Private Equity Performance

BERNSTEIN POLYNOMIALS

Support Vector Machines

Section 5.3 Annuities, Future Value, and Sinking Funds

How To Calculate An Approxmaton Factor Of 1 1/E

Extending Probabilistic Dynamic Epistemic Logic

Lecture 3: Annuity. Study annuities whose payments form a geometric progression or a arithmetic progression.

v a 1 b 1 i, a 2 b 2 i,..., a n b n i.

Compiling for Parallelism & Locality. Dependence Testing in General. Algorithms for Solving the Dependence Problem. Dependence Testing

A hybrid global optimization algorithm based on parallel chaos optimization and outlook algorithm

Lecture 2 Sequence Alignment. Burr Settles IBS Summer Research Program 2008 bsettles@cs.wisc.edu

The OC Curve of Attribute Acceptance Plans

Causal, Explanatory Forecasting. Analysis. Regression Analysis. Simple Linear Regression. Which is Independent? Forecasting

Answer: A). There is a flatter IS curve in the high MPC economy. Original LM LM after increase in M. IS curve for low MPC economy

NMT EE 589 & UNM ME 482/582 ROBOT ENGINEERING. Dr. Stephen Bruder NMT EE 589 & UNM ME 482/582

Usage of LCG/CLCG numbers for electronic gambling applications

A Performance Analysis of View Maintenance Techniques for Data Warehouses

Texas Instruments 30X IIS Calculator

General Auction Mechanism for Search Advertising

Practical Issues and Algorithms for Analyzing Terrorist Networks 1

Section 5.4 Annuities, Present Value, and Amortization

An Analysis of Central Processor Scheduling in Multiprogrammed Computer Systems

Nonbinary Quantum Error-Correcting Codes from Algebraic Curves

Lecture 3: Force of Interest, Real Interest Rate, Annuity

Time Value of Money Module

Solution: Let i = 10% and d = 5%. By definition, the respective forces of interest on funds A and B are. i 1 + it. S A (t) = d (1 dt) 2 1. = d 1 dt.

Examensarbete. Rotating Workforce Scheduling. Caroline Granfeldt

Formulating & Solving Integer Problems Chapter

QUESTIONS, How can quantum computers do the amazing things that they are able to do, such. cryptography quantum computers

Face Verification Problem. Face Recognition Problem. Application: Access Control. Biometric Authentication. Face Verification (1:1 matching)

Vision Mouse. Saurabh Sarkar a* University of Cincinnati, Cincinnati, USA ABSTRACT 1. INTRODUCTION

Multiple-Period Attribution: Residuals and Compounding

Calculating the high frequency transmission line parameters of power cables

Efficient Reinforcement Learning in Factored MDPs

CHOLESTEROL REFERENCE METHOD LABORATORY NETWORK. Sample Stability Protocol

THE METHOD OF LEAST SQUARES THE METHOD OF LEAST SQUARES

Frequency Selective IQ Phase and IQ Amplitude Imbalance Adjustments for OFDM Direct Conversion Transmitters

The circuit shown on Figure 1 is called the common emitter amplifier circuit. The important subsystems of this circuit are:

How To Calculate The Accountng Perod Of Nequalty

Risk-based Fatigue Estimate of Deep Water Risers -- Course Project for EM388F: Fracture Mechanics, Spring 2008

CS 2750 Machine Learning. Lecture 3. Density estimation. CS 2750 Machine Learning. Announcements

An Enhanced Super-Resolution System with Improved Image Registration, Automatic Image Selection, and Image Enhancement

How To Know The Components Of Mean Squared Error Of Herarchcal Estmator S

Maintenance Scheduling by using the Bi-Criterion Algorithm of Preferential Anti-Pheromone

Product-Form Stationary Distributions for Deficiency Zero Chemical Reaction Networks

Traffic-light a stress test for life insurance provisions

Time Value of Money. Types of Interest. Compounding and Discounting Single Sums. Page 1. Ch. 6 - The Time Value of Money. The Time Value of Money

1 What is a conservation law?

A Secure Password-Authenticated Key Agreement Using Smart Cards

Certificate Revocation using Fine Grained Certificate Space Partitioning

A Novel Methodology of Working Capital Management for Large. Public Constructions by Using Fuzzy S-curve Regression

An Overview of Financial Mathematics

RESEARCH ON DUAL-SHAKER SINE VIBRATION CONTROL. Yaoqi FENG 1, Hanping QIU 1. China Academy of Space Technology (CAST)

INSTITUT FÜR INFORMATIK

Robust Design of Public Storage Warehouses. Yeming (Yale) Gong EMLYON Business School

Learning with Imperfections A Multi-Agent Neural-Genetic Trading System. with Differing Levels of Social Learning

A Prefix Code Matching Parallel Load-Balancing Method for Solution-Adaptive Unstructured Finite Element Graphs on Distributed Memory Multicomputers

A DATA MINING APPLICATION IN A STUDENT DATABASE

On fourth order simultaneously zero-finding method for multiple roots of complex polynomial equations 1

OPTIMAL INVESTMENT POLICIES FOR THE HORSE RACE MODEL. Thomas S. Ferguson and C. Zachary Gilstein UCLA and Bell Communications May 1985, revised 2004

Types of Injuries. (20 minutes) LEARNING OBJECTIVES MATERIALS NEEDED

SIMPLE LINEAR CORRELATION

Betting on Permutations

2008/8. An integrated model for warehouse and inventory planning. Géraldine Strack and Yves Pochet

Transcription:

Lecture 1 (18.11.2012) Varous Technques Author: Jaros law B lasok The followng lecture s dvded nto three parts, n the frst one we wll consder the Subset Sum problem and see how to solve t usng varaton over the well-known meet-n-the-mddle technque. The second part wll consst of nterestng applcaton of dvde-and-conquer n desgnng moderately exponental algorthms. In thrd part we wll get famlar wth the memozaton technque and see how to apply t to the Perfect Matchng Count problem. 1 Subset Sum problem 1.1 Introducton Subset Sum Input: Sequence of n ntegers a 1, a 2, a n and an nteger S Queston: Is there any subset of ndces { 1, k } such that a 1 + a 2 + + a k = S It s well known that the above problem s NP-complete, there s trval soluton wth computatonal complexty O (2 n ) and space complexty O (1). There s also classc dynamc pseudopolynomal algorthm whch solves that problem n tme O(nS) and space O(S). Those two are gong to be our base for further mprovements. Our goal at ths pont s to fnd soluton more effectve than 2 n, ndependent on S, havng n mnd space complexty (ths s relevant when S s large). 1.2 k-sum problem Let us reformulate the above problem and generalze t a lttle n order to have a better sght. Consder the followng problem:

k-sum problem Input: k sequences of ntegers (a j )n =1 for 1 j k and an nteger S. Queston: Are there ndces 1, 2,, k, s. t. k a j j = S j=1 Remark 1. The Subset Sum problem can be reduced to the k-sum problem for any k, where n s 2 n/k. Indeed, gven an nstance of the Subset Sum problem, say: (a 1, a 2, a n ; S) one mght take an nstance of the k-sum problem as (a 1 ) n =1 beng sequence of sums of all subsets of a 1, a 2, a n, (a2 ) n k =1 are all sums of subsets of second block of length n and so on. Now each choce of ndces j n k-sum problem s the same as determnng what s the ntersecton of an unknown subset for the Subset Sum problem wth the blocks k n k,... (k + 1) n k 1. Remark 2. The k-sum problem can be solved n tme O(n k ) (trvally). Note that the remark above alone s useless for our purpose: after reducng Subset Sum to k-sum as above and applyng ths trval soluton we acqure soluton wth complexty O (2 n ) to Subset Sum. 1.3 2-Sum problem In order to get better algorthm for the subset sum problem, we focus on tryng to solve the k-sum problem for some partcular k better than n O(n k ). Lets start wth 2-Sum. For fxed 1 we do know we have chosen a 1 1, what we want to check s f there exsts S a 1 1 n the second sequence. It suffces then to sort the second sequence n advance, to make those queres easy. Corollary 3. The 2-Sum problem can be solved n tme O(n log n) and lnear space. Corollary 4. The Subset Sum problem can be solved n tme O (2 n 2 ) and space O (2 n 2 ). 1.4 4-Sum Our next goal s to mprove space complexty, preservng tme complexty.

Lets make precse algorthm for k = 2: Sort frst sequence n the ncreasng, and second one n the decreasng order. Now one can solve the k-sum problem lnearly, movng two ponters smultaneously, as below: whle n&j n do z = a 1 + a2 j f z = S then END end f f z < S then Increment end f f z > S then Increment j end f end whle Lets now try to solve the 4-Sum problem n O(n 2 ) tme and lnear space. It would gve us Subset Sum soluton n tme O (2 n 2 ) and space O (2 n 4 ) va reducton from above. We want to modfy the algorthm from above: t would be suffcent to be able to effcently generate all pars of ndces 1, 2 n the order of ncreasng value a 1 1 + a 2 2 we would do the same wth 3, 4, generatng them n decreasng order and apply the algorthm from above. Indeed, one can generate all such pars n O(n) space and O(n 2 log n) tme. Lets sort both sequences a 1 and a 2 n the ncreasng order, and mantan a heap wth pars of actve ndces: at any pont n the heap for every 1 {1 n} there s exactly one par of actve ndces ( 1, 2 ): 2 beng the lowest s.t. that par have not yet been generated. Heap s ordered by a 1 1 + a 2 2, now at each pont there s exactly n elements n heap. When we re asked for the next par, one just takes the frst actve par from the heap (.e. the one wth smallest value a 1 1 + a 2 2 and put the par ( 1, 2 + 1) nto the heap as actve. That leads us to the followng corollares, proved by Schroeppel and Shamr [3]. Corollary 5. The 4-Sum problem can be solved n O(n 2 log n) tme and lnear space. Corollary 6. The Subset Sum problem can be solved n O (2 n 2 ) tme and O (2 n 4 ) space. Those are currently best-known bounds for ths problem. There are

two mportant open queston around ths topc: s there any algorthm to the Subset Sum problem whch solves t n polynomal space, and tme complexty O ((2 ε) n )? Is t possble to acheve better tme complexty than O (2 n 2 )? 2 Dvde and conquer 2.1 Introducton; Travelng Salesman Problem Lets take a look nto the very well known dvde-and-conquer technque and ts applcaton n desgnng moderate exponental algorthm for one of the most famous NP-hard problems. Travelng Salesman Problem Input: Drected, weghted graph G Queston: Cheapest Hamlton cycle n G The dynamc programmng soluton presented n one of the prevous lectures for the Hamlton Cycle problem s stll vald: for every state n dynamc programmng, one keeps nformaton about cheapest partal soluton. That leads to a soluton wth tme complexty O (2 n ) and space complexty O (2 n ). The soluton based on the ncluson-excluson prncple can t be extended to ths generalzed case. 2.2 Soluton Our goal now s to get an algorthm of tme complexty O (c n ) and polynomal space complexty. It s obvous that our problem s polynomally equvalent to the problem of fndng the cheapest Hamlton path between s and t for fxed s, t. We wll consder ths problem from now on. It would suffce to guess properly a vertex v whch s n the mddle of the cheapest path, then for every other vertex of the graph guess on whch sde of ths vertex t s on ths path. Now we could solve two smaller problems ndependently. More precsely: for each vertex v V, and for each dvson V \{s, t, v} = V 1 V 2 nto two sets s.t. V 1 V 2 = and V 1 = n 3 2, solve recursvely ndependent nstances: (G[V 1 {s, v}], s, v) (G[V 2 {v, t}], v, t)

Ths gves us recursve equaton of tme complexty: Wth rather easy soluton: T (n) = n 2 n 2 T (n/2) T (n) = O (n log n 4 n ) Corollary 7. There s an algorthm for the Travelng Salesman Problem of tme complexty O ((4 + ε) n ) and space complexty O (1). 3 Memozaton 3.1 Introducton; Perfect Matchng Countng problem At ths part of lecture we wll dscuss memozaton, whch s effectvely another way of lookng at the dynamc programmng method. Wth a careful examnaton, one mght recognze that not all states of dynamc programmng are relevant to the fnal soluton, so wth a top-down mplementaton and more precse analyss t s possble to acqure a better tme complexty sometmes by cost of a lttle worse space complexty. We wll see an example of how one can use memozaton to solve the Perfect Matchng Countng problem, defned as follows: Perfect Matchng Countng Input: An undrected graph G wth n vertces Queston: Calculate how many there are dfferent 1-regular subgraphs of G on n vertces (perfect matchngs of G) 3.2 Soluton There s an obvous dynamc soluton for the problem posted above: for every subset X of set V one wants to calculate T [X] as the number of perfect matchngs n G[X]. Now a soluton for our problem s just T [V ], and there s a recursve formula for calculatng T [X]: for a set X we fx a vertex v X wth the smallest ndex. Now: T [X] = t[x \ {u, v}] uv E Theres an obvous upper bound of O (2 n ) on the complexty of the above algorthm, but maybe we could do better than ths, and examne whch felds of T [X] are relevant. The followng lemma wll be helpful:

Lemma 8. If recurson touches a set X of sze n 2, X {v 1, v 2,, v } = Proof. Trval, as at every pont we remove two vertces, one of them havng smallest ndex among all remanng. Now t follows drectly from the lemma above, that number of states we are tryng to estmate does not exceed: n/2 ( ) n One can easly (but somehow strkngly) bound ths sum from above: n/2 ( ) n ( ) n = F n+1 whle the latter equalty follows from smple nducton: ( ) n ( ) n 1 ( ) n 1 = + 1 ( ) n 2 = F n + = 1 = F n + F n 1 = F n+1 Ths leads to the followng algorthm by Kovsto [2]. Corollary 9. There exst an algorthm for the Perfect Matchng Countng problem whch runs n O (( 1+ 5 2 ) n ) tme and space complexty. Informal, but useful hnt: Durng desgnng ths knd of algorthms often suffces to see that number of subsets of sze roughly n 2 whch are vsted durng recurson s strctly less (asymptotcally) than 2 n. 4 Perfect Matchng Countng once agan In ths secton there wll be presented a sketch of a soluton n tme O (2 n/2 ) for the Perfect Matchng Countng problem. Space could be lmted to polynomal. The algorthm below s a smplfcaton of the algorthm of Björklund [1]. Lets take a graph G, mark ts edges as black, then add n/2 red edges: v 1 v 2, v 3 v 4, ; that leads us to a multgraph G wth black and red edges.

Remark 10. The number of perfect matchngs n G equals the number of cycle covers of G, where every cycle s alternatng (even edges are black, odds are red). We want to calculate ths number faster (n tme O (2 n/2 )). Lets use the ncluson-excluson prncple, as n one of the prevous lectures. Defne Ω as the set of all tuples of closed alternatng walks of sum of length n. A Ω are those whch contan the -th red edge. What we want to calculate s A, and t s farly smple by ncluson-excluson prncple. Yet, t s stll not a soluton, as same matchng s taken nto account more than once. If we take Ω d beng d-tuples as above, our number of perfect matchng s roughly: A d /d! (1) d 1 n 2 One mnor ssue one has to work out are automorphsms of any sngle cycle, but t s possble to get through t. References [1] Andreas Björklund. Countng perfect matchngs as fast as ryser. In Yuval Raban, edtor, SODA, pages 914 921. SIAM, 2012. [2] Mkko Kovsto. Parttonng nto sets of bounded cardnalty. In Janer Chen and Fedor V. Fomn, edtors, IWPEC, volume 5917 of Lecture Notes n Computer Scence, pages 258 263. Sprnger, 2009. [3] Rchard Schroeppel and Ad Shamr. A T=O(2 n/2 ), S=O(2 n/4 ) algorthm for certan NP-complete problems. SIAM J. Comput., 10(3):456 464, 1981.