Fixed-Parameter Algorithms for Longest Heapable Subsequence and Maximum Binary Tree
Total Page:16
File Type:pdf, Size:1020Kb
Fixed-Parameter Algorithms for Longest Heapable Subsequence and Maximum Binary Tree Karthekeyan Chandrasekaran∗ Elena Grigorescuy Gabriel Istratez Shubhang Kulkarniy Young-San Liny Minshen Zhuy November 23, 2020 Abstract A heapable sequence is a sequence of numbers that can be arranged in a min-heap data structure. Finding a longest heapable subsequence of a given sequence was proposed by Byers, Heeringa, Mitzenmacher, and Zervas (ANALCO 2011) as a generalization of the well-studied longest increasing subsequence problem and its complexity still remains open. An equivalent formulation of the longest heapable subsequence problem is that of finding a maximum-sized binary tree in a given permutation directed acyclic graph (permutation DAG). In this work, we study parameterized algorithms for both longest heapable subsequence as well as maximum-sized binary tree. We show the following results: 1. The longest heapable subsequence problem can be solved in kO(log k)n time, where k is the number of distinct values in the input sequence. 2. We introduce the alphabet size as a new parameter in the study of computational prob- lems in permutation DAGs. Our result on longest heapable subsequence implies that the maximum-sized binary tree problem in a given permutation DAG is fixed-parameter tractable when parameterized by the alphabet size. 3. We show that the alphabet size with respect to a fixed topological ordering can be com- puted in polynomial time, admits a min-max relation, and has a polyhedral description. 4. We design a fixed-parameter algorithm with run-time wO(w)n for the maximum-sized bi- nary tree problem in undirected graphs when parameterized by treewidth w. Our results make progress towards understanding the complexity of the longest heapable sub- sequence and maximum-sized binary tree in permutation DAGs from the perspective of param- eterized algorithms. We believe that the parameter alphabet size that we introduce is likely to be useful in the context of optimization problems defined over permutation DAGs. 1 Introduction The longest increasing subsequence is a fundamental computational problem that has led to nu- merous discoveries in algorithms as well as combinatorics. The motivation behind this work is a ∗University of Illinois, Urbana-Champaign, Email: [email protected] yPurdue University, Email: {elena-g, kulkar17, lin532, zhu628}@purdue.edu zWest University of Timişoara, Romania, and the e-Austria Research Institute. Email: [email protected] 1 generalization of the longest increasing subsequence problem, known as the longest heapable subse- quence problem, introduced by Byers, Heeringa, Mitzenmacher, and Zervas [BHMZ11]. We begin by defining this problem. A rooted tree whose nodes are labeled with values has the heap prop- erty if the value of every node is at least that of its parent; a sequence of natural numbers is heapable if the elements can be sequentially placed one at a time to form a binary tree with the heap property. For example, the sequence 1; 5; 3; 2; 4 is not heapable while the sequence 1; 3; 3; 2; 4 is heapable. Throughout this work, we will be interested in sequences whose elements are natural numbers. In the longest heapable subsequence problem, the goal is to find a longest heapable sub- sequence of a given sequence. Although the longest increasing subsequence problem is solvable in polynomial-time, the complexity of the longest heapable subsequence problem is still open. The problem of verifying if a given sequence is heapable, although non-trivial, is solvable effi- ciently using a greedy approach [BHMZ11]. In order to address the longest heapable subsequence problem, Porfilio [Por15] observed a connection to a graph problem on directed acyclic graphs (DAGs). The permutation DAG associated with a sequence σ = (σ(1); σ(2); : : : ; σ(n)), denoted PermDAG(σ), is obtained by introducing a vertex ti for every sequence element i 2 [n], and arcs (tj; ti) for every i; j 2 [n] such that i < j and σ(i) ≤ σ(j). We recall that a directed graph G is a permutation DAG if there exists a sequence τ such that G is isomorphic to PermDAG(τ). We need the notion of a binary tree in a given directed graph G: a subgraph T of G is an r-rooted binary tree if r is the unique vertex in T with no outgoing edges, every vertex in T has a unique directed path to r in T , and every vertex in T has in-degree at most 2 in T ; the size of T is the number of vertices in T . Porfilio showed that a longest heapable subsequence of a given sequence σ is equivalent to a maximum-sized binary tree in PermDAG(σ). This result raises the question of whether one can efficiently find a maximum-sized binary tree in a given permutation DAG. The complexity of this problem also remains open. In an earlier work [CGI+20], we showed that maximum-sized binary tree in arbitrary input directed graphs is fixed-parameter tractable when parameterized by the solution size: we gave a 2knO(1) time algorithm, where k is the size of the largest binary tree and n is the number of vertices in the input graph. This also implies that the longest heapable subsequence problem is fixed-parameter tractable when parameterized by the solution size. In this work, we consider two alternative parameterizations for the maximum-sized binary tree/longest heapable subsequence problem. Firstly, we show that the longest heapable subsequence problem is fixed-parameter tractable when parameterized by the number of distinct values in the input sequence. Next, we introduce alphabet size as a new parameter in the study of computational problems in permutation DAGs. Our algorithmic result for longest heapable subsequence problem implies that the maximum-sized binary tree problem in a given permutation DAG is fixed-parameter tractable when parameterized by the alphabet size. We currently do not know how to compute the alphabet size of a given permutation DAG. As a stepping stone towards computing alphabet size, we show that alphabet size with respect to a fixed topological ordering can be computed efficiently and it also admits a min-max relation and a polyhedral description. Our results suggest that alphabet size is an interesting parameterization for computational problems defined on permutation DAGs and merits a thorough study. Finally, we design a fixed-parameter algorithm for the maximum-sized binary tree problem in undirected graphs when parameterized by treewidth. We elaborate on our contributions now. 2 1.1 Results Our first result shows that the longest heapable subsequence problem is fixed-parameter tractable when parameterized by the number of distinct values in the sequence. Theorem 1. There exists an algorithm that takes as input an n-length sequence τ with k distinct values and returns a longest heapable subsequence of τ in time (k + 1)! · k · O(n). Equivalently, our algorithm returns a maximum-sized binary tree in PermDAG(τ). We emphasize that our algorithm also works in the streaming model of computation—i.e., when the input sequence arrives one by one and the algorithm has to find the longest heapable subsequence of the input that has arrived so far (in particular, the algorithm is not allowed to store the entire input sequence). The space complexity of our algorithm is (k + 1)! · k · O(log n) and is logarithmic for constant k. Theorem1 can also be viewed as a fixed-parameter algorithm to find a maximum-sized binary tree in a given permutation DAG when parameterized by alphabet size. We define this parameter now. We note that for a fixed permutation DAG G, there could be several sequences τ such that G(τ) is isomorphic to G. This motivates our parameterization for permutation DAGs: The alphabet size of a permutation DAG G, denoted α(G), is defined as follows (see Figure1 for an example): α(G) := minfk : 9 τ 2 [k]n with PermDAG(τ) being isomorphic to Gg: We recall that directed graphs G = (V; A) and G0 = (V;0 ;A0) are isomorphic if there exists a bijection φ : V 0 ! V such that (u0; v0) 2 A0 if and only if (φ(u0); φ(v0)) 2 A. Theorem1 also implies that there exists an algorithm that takes as input, an n-vertex permutation DAG G and a sequence τ with α(G) = k distinct values such that G(τ) is isomorphic to G and returns a maximum-sized binary tree in G in time (k + 1)! · k · O(n). b a d c G a b c d c a d b PermDAG(τ1 = (2; 3; 1; 2)) PermDAG(τ2 = (2; 1; 2; 1)) Figure 1: Let G be the input permuation DAG. The graph G is isomorphic to PermDAG(τ1) and PermDAG(τ2). The sequence τ1 = (2; 1; 2; 1) uses only two distinct values, which turns out to be the minimum, so α(G) = 2. Next, we explore algorithmic aspects of our newly defined parameter, namely the alphabet size. A natural question is whether the alphabet size of a given permutation DAG can be computed in polynomial-time. Currently, we do not know the answer to this question. However, there is a natural related problem that seems like a stepping stone towards resolving the complexity of computing the alphabet size of permutation DAGs. We define this related problem now. 3 We recall that every DAG G = (V; A) admits a topological ordering—a bijection γ : V ! [n] corresponding to a permutation of its n vertices such that every arc (v; u) 2 A has γ(u) < γ(v) (i.e., all edges are oriented in the backward direction with respect to the ordering defined by γ).