Fast and Simple Modular Subset Sum

We revisit the Subset Sum problem over the finite cyclic group $\mathbb{Z}_m$ for some given integer $m$. A series of recent works has provided asymptotically optimal algorithms for this problem under the Strong Exponential Time Hypothesis. Koiliaris and Xu (SODA'17, TALG'19) gave a deterministic algorithm running in time $\tilde{O}(m^{5/4})$, which was later improved to $O(m \log^7 m)$ randomized time by Axiotis et al. (SODA'19). In this work, we present two simple algorithms for the Modular Subset Sum problem running in near-linear time in $m$, both efficiently implementing Bellman's iteration over $\mathbb{Z}_m$. The first one is a randomized algorithm running in time $O(m\log^2 m)$, that is based solely on rolling hash and an elementary data-structure for prefix sums; to illustrate its simplicity we provide a short and efficient implementation of the algorithm in Python. Our second solution is a deterministic algorithm running in time $O(m\ \mathrm{polylog}\ m)$, that uses dynamic data structures for string manipulation. We further show that the techniques developed in this work can also lead to simple algorithms for the All Pairs Non-Decreasing Paths Problem (APNP) on undirected graphs, matching the asymptotically optimal running time of $\tilde{O}(n^2)$ provided in the recent work of Duan et al. (ICALP'19).

[1]  Marek Cygan,et al.  On problems equivalent to (min, +)-convolution , 2017, ICALP.

[2]  Raphael Yuster,et al.  All Pairs Bottleneck Paths and Max-Min Matrix Products in Truly Subcubic Time , 2009, Theory Comput..

[3]  Dvir Shabtay,et al.  SETH-based Lower Bounds for Subset Sum and Bicriteria Path , 2017, SODA.

[4]  Ran Duan,et al.  Faster Algorithms for All Pairs Non-decreasing Paths Problem , 2019, ICALP.

[5]  Piotr Sankowski,et al.  Optimal Dynamic Strings , 2015, SODA.

[6]  Virginia Vassilevska Williams,et al.  Multiplying matrices faster than coppersmith-winograd , 2012, STOC '12.

[7]  Kurt Mehlhorn,et al.  Maintaining dynamic sequences under equality tests in polylogarithmic time , 1994, SODA '94.

[8]  Mohammad Taghi Hajiaghayi,et al.  Fast algorithms for knapsack via convolution and prediction , 2018, STOC.

[9]  Christos Tzamos,et al.  Fast Modular Subset Sum using Linear Sketching , 2018, SODA.

[10]  François Le Gall,et al.  Powers of tensors and fast matrix multiplication , 2014, ISSAC.

[11]  Christos Tzamos,et al.  Capacitated Dynamic Programming: Faster Knapsack and Graph Algorithms , 2018, ICALP.

[12]  Friedrich Eisenbrand,et al.  Proximity Results and Faster Algorithms for Integer Programming Using the Steinitz Lemma , 2017, SODA.

[13]  Ce Jin,et al.  A Simple Near-Linear Pseudopolynomial Time Randomized Algorithm for Subset Sum , 2019, SOSA@SODA.

[14]  Timothy M. Chan Approximation Schemes for 0-1 Knapsack , 2018, SOSA.

[15]  G. Brodal,et al.  Dynamic Pattern Matching , 2009 .

[16]  Virginia Vassilevska Williams,et al.  Nondecreasing paths in a weighted graph or: How to optimally read a train schedule , 2010, TALG.

[17]  Karl Bringmann,et al.  A Near-Linear Pseudopolynomial Time Algorithm for Subset Sum , 2016, SODA.

[18]  Le Zhang,et al.  Improved Time Bounds for All Pairs Non-decreasing Paths in General Digraphs , 2018, ICALP.

[19]  Donguk Rhee,et al.  Faster fully polynomial approximation schemes for Knapsack problems , 2015 .

[20]  Klaus Jansen,et al.  On Integer Programming and Convolution , 2019, ITCS.

[21]  Ran Duan,et al.  Fast algorithms for (max, min)-matrix multiplication and bottleneck shortest paths , 2009, SODA.

[22]  Erik D. Demaine,et al.  Logarithmic Lower Bounds in the Cell-Probe Model , 2005, SIAM J. Comput..

[23]  Peter M. Fenwick,et al.  A new data structure for cumulative frequency tables , 1994, Softw. Pract. Exp..

[24]  R. Bellman Dynamic programming. , 1957, Science.

[25]  Stephen Alstrup,et al.  Pattern matching in dynamic texts , 2000, SODA '00.

[26]  Chao Xu,et al.  Faster Pseudopolynomial Time Algorithms for Subset Sum , 2019, ACM Trans. Algorithms.

[27]  Yahya Ould Hamidoune,et al.  On complete subsets of the cyclic group , 2007, J. Comb. Theory, Ser. A.

[28]  Ce Jin,et al.  An Improved FPTAS for 0-1 Knapsack , 2019, ICALP.

[29]  Marvin Künnemann,et al.  On the Fine-grained Complexity of One-Dimensional Dynamic Programming , 2017, ICALP.

[30]  Don Coppersmith,et al.  Matrix multiplication via arithmetic progressions , 1987, STOC.