Abstract 1 Introduction References Appendix A Preliminaries Appendix B Bottom-up divide and conquer Appendix C Disjunctive and minimizing problems Appendix D Longest Distinct Substring

On the Quantum Time Complexity of Divide and Conquer

Jonathan Allcock ORCID Tencent Quantum Laboratory, Hong Kong, China Jinge Bao ORCID School of Informatics, University of Edinburgh, UK
Centre for Quantum Technologies, National University of Singapore, Singapore
Aleksandrs Belovs ORCID Center for Quantum Computing Science, Faculty of Science and Technology, University of Latvia, Riga, Latvia Troy Lee Centre for Quantum Software and Information, University of Technology Sydney, Ultimo, Australia Miklos Santha Centre for Quantum Technologies, National University of Singapore, Singapore
CNRS, IRIF, Paris, France
Abstract

In this work, we initiate a systematic study of the time complexity of quantum divide and conquer (QD&C) algorithms for classical problems, and propose a general framework for their analysis. We establish generic conditions under which search and minimization problems with classical divide and conquer algorithms are amenable to quantum speedup, and apply these theorems to various problems involving strings, integers, and geometric objects. These include Longest Distinct Substring, Klee’s Coverage, several optimization problems on stock transactions, and k-Increasing Subsequence. For most of these problems our quantum time upper bounds match the quantum query lower bounds, up to polylogarithmic factors.

We give a structured framework for describing and classifying a wide variety of QD&C algorithms so that quantum speedups can be more easily identified and applied, and prove general statements on QD&C time complexity covering a range of cases, accounting for the time required for all operations. In particular, we explicitly account for memory access operations in the commonly used 𝖰𝖱𝖠𝖬 (read-only) and 𝖰𝖱𝖠𝖦 (read-write) models, which are assumed to take unit time in the query model, and which require careful analysis when involved in recursion.

Our generic QD&C theorems have several nice features.

  1. 1.

    To apply them, it suffices to come up with a classical divide and conquer algorithm satisfying the conditions of the theorem. The quantization of the algorithm is then completely handled by the theorem. This can make it easier to find applications which admit a quantum speedup, and contrast with dynamic programming algorithms which can be difficult to quantize due to their highly sequential nature.

  2. 2.

    As these theorems give bounds on time complexity, they can be applied to a greater range of problems than those based on query complexity, e.g., where the best-known quantum algorithms require super-linear time.

  3. 3.

    It can handle minimization problems as well as boolean functions, which allows us to improve on the query complexity result of Childs et al. [13] for k-Increasing Subsequence by a logarithmic factor.

Keywords and phrases:
Quantum Computing, Quantum Algorithms, Divide and Conquer
Category:
Track A: Algorithms, Complexity and Games
Copyright and License:
[Uncaptioned image] © Jonathan Allcock, Jinge Bao, Aleksandrs Belovs, Troy Lee, and Miklos Santha; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Quantum computation theory
Related Version:
Full Version: https://arxiv.org/abs/2311.16401 [4]
Funding:
This project was supported by the National Research Foundation, Singapore through the National Quantum Office, hosted in A*STAR, under its Centre for Quantum Technologies Funding Initiative (S24Q2d0009). A.B. is supported by the QuantERA ERA-NET project QOPT. T.L. is supported in part by the ARC DP grant DP200100950. J.B. is supported by the Quantum Advantage Pathfinder (QAP) project of the UKRI Engineering and Physical Sciences Research Council (Grant No. EP/X026167/1), and was funded by a CQT PhD Scholarship when the work was initialized.
Editors:
Keren Censor-Hillel, Fabrizio Grandoni, Joël Ouaknine, and Gabriele Puppis

1 Introduction

Divide and conquer is a basic algorithmic technique that gained prominence in the 1960s via a series of beautiful and powerful algorithms for fundamental problems including integer multiplication [25], sorting [22], the Fourier transform [14] and matrix multiplication [28]. In fact, the technique of divide and conquer was already used much earlier: Gauss designed the first fast Fourier transform algorithm in 1805, published only after his death [17, 21], and von Neumann invented mergesort in 1945 [19].

Divide and conquer algorithms do not have a generic mathematical description unlike, for example, greedy algorithms. Similarly, there are no known combinatorial structures on which they achieve optimality, unlike greedoids where the greedy solution is optimal for a large class of objective functions [27]. In order to capture the variety of divide and conquer algorithms, it is helpful to keep three examples in mind: quicksort, mergesort, and a divide and conquer algorithm for the Single Stock Single Transaction (SSST) problem, where the goal is to compute argmaxi<jAjAi for a given array An. We assume that the reader is familiar with quicksort and mergesort. The divide and conquer algorithm for SSST is based on the principle that the indices achieving the maximum are either both contained in the left half of the array, both contained in the right half of the array, cases that can be solved recursively, or one is contained in the left half and one in the right half. The latter case can be directly solved because in this case AjAi is maximized when Aj is the maximum value in the second half of A and Ai is the minimum value in the first half of A.

With these examples in mind, we break down the work in a divide and conquer algorithm into four C’s: create, conquer, complete, and combine. In the create (or divide) step the algorithm constructs the subproblems to be solved. In mergesort, the construction of subproblems is trivial as this simply involves dividing a string into left and right halves. In quicksort, on the other hand, the create step is where the main work of partitioning the input into elements at most the pivot and at least the pivot takes place. In the conquer step the algorithm (typically recursively) solves the subproblems created in the previous step. In the complete step the algorithm computes anything that is needed to solve the original problem but not contained in the solution to the subproblems. SSST is a prime example of this step, as here in the complete step one solves the special case of finding the maximum profit when buying in the first half of the array and selling in the second half. Finally in the combine step the algorithm integrates the solutions to the subproblems and from the complete step to solve the original problem. A canonical example of this is the merge step of mergesort. Table 1 summarizes this discussion.

Table 1: Breakdown of the steps in a divide and conquer algorithm.
Description Example
Create Create subproblems. Partition step of quicksort.
Conquer Solve subproblems. Recursive call to quicksort.
Complete Compute additional information not covered by subproblems. In SSST, the maximum profit from buying in the first half, and selling in the second half.
Combine Combine subproblem solutions to solve the original problem. The merge step of mergesort.

Classical divide and conquer algorithms are usually analyzed in the RAM model where accessing a memory register containing an element of the input string takes constant time. Our quantum algorithms will be given in two quantum memory models. In both cases, we assume coherent access to the memory register, that is, the index register can store a superposition of addresses. The first model we consider is 𝖰𝖱𝖠𝖬, where the access to data is read-only, and we further assume that the data stored is classical, i.e., the memory register is not in superposition. The second model we consider is 𝖰𝖱𝖠𝖦, where both reading and writing to memory are permitted, and we assume the memory register itself can be in superposition (indeed we require this in some of our algorithms). By a query we mean any of these memory operations. While we also will derive query complexity results about our algorithms, our main emphasis will be on time complexity. For a memory of size N, we denote the time required to perform a 𝖰𝖱𝖠𝖬 or 𝖰𝖱𝖠𝖦 query by parameters QRN (quantum reading) and QWN (quantum writing), respectively. Standard one and two-qubit quantum operations are counted as one time step. The exact definition of these models is given in Appendix A.

1.1 Our contributions

Table 2: Applications of our divide and conquer technique in the third column, assuming quantum memory access times QRn,QWn=O(log2n) (see Section A.2.2). For each sublinear quantum upper bound, there is a simple quantum query lower bound that matches up to a polylogarithmic factor.
Classical Time Quantum Time
Longest Distinct Substring O~(n) O~(n2/3)
Klee’s Coverage  in d O(nd/2),d3 [12] O(nd/4+ε),d8
Single Stock Single Transaction O(n) O(nlog5/2(n))
k-Increasing Subsequence
k-Signed Sum
O(nloglogk) [15]
O~(n)
O(nlogk+1(n)(loglogn)k1)
Maximum 4-Combination O(n3) [8] O(n3/2log5/2(n))

In this work, we focus on divide and conquer algorithms where the combine step is either the OR function or minimization/maximization, meaning that it is amenable to a quantum speedup by Grover search or quantum minimum/maximum finding. When the complete step is also relatively simple, we can show a generic theorem that transforms a classical divide and conquer algorithm into a quantum one and bounds its time complexity. We show two versions of this theorem depending on the nature of the create step.

Our generic quantum divide and conquer theorems have several nice features. The first is that, to apply them, it suffices to come up with a classical divide and conquer algorithm satisfying the conditions of the theorem. The quantization of this algorithm is then completely handled by the theorem. This can make it easier to find applications of these theorems. The second is that these theorems give bounds on time complexity, not just the query complexity. To the best of our knowledge, the quantum time complexity of the divide and conquer method has not been systematically studied before. Working with time complexity also lets us apply these theorems to a greater range of problems, e.g. those where the best-known classical algorithms require super-linear time.

As divide and conquer algorithms are typically recursive, our theorems must handle the error probability corresponding to the composition of a super-constant number of bounded-error algorithms. While the composition of bounded-error quantum algorithms is now well understood in the quantum query complexity setting, much less work has focused on this in the time complexity setting [9]. We show several basic results about the time complexity of the composition of quantum search or minimum/maximum finding over bounded-error subroutines. In most cases, these results are relatively easy adaptations of analogous algorithms in the query setting. However, we feel these are fairly fundamental algorithmic primitives that will find further application in the future.

The statement of our quantum divide and conquer theorems is rather technical and we defer a discussion to section 1.2, and give further details in Appendix B and Appendix C. In the rest of this section, we describe applications of our generic theorems to different problems. A summary of the major applications can be found in Table 2, where we assume that the cost of the two memory access gates is O(log2n), as per some proposals for implementations of quantum memory (see Section A.2.2).

Some problems have a simple create step, by which we mean that the locations of the subproblems are identical for all inputs of the same size. The quantum algorithm we give for Single Stock Single Transaction turns out to be quite paradigmatic, and we are able to use a very similar approach for the following three problems. In the Longest Increasing Substring problem (LISst), we have to find the longest increasing substring in an array of integers. In the Longest Identical Substring problem (LSIC), we are looking for the longest substring of identical characters in a string over some finite alphabet. Finally, in the Longest 202 Substring problem (L202S) we have to find the longest substring belonging to 202 in a string from {0,1,2}. All these problems can be solved by classical divide and conquer along the lines of the algorithm we sketched for Single Stock Single Transaction, in time O(nlogn), and they require time Ω(n). Our algorithms achieve an almost quadratic quantum speed up. For the rest of the paper, for k1, we define the function

λk(n,m)=min{logkn+m,log(k+1)/2(n)(loglogn)k1+log(k1)/2(n)(loglogn)k1m}.

Observe that for k=1 we have λ1(n,QRn)=logn+QRn, and for k=2 we have λ2(n,QRn)=min{log2n+QRn,log3/2(n)loglogn+lognloglognQRn}.

Theorem 1.

The quantum query and time complexities of the problems SSST, LISst, LSIC and L202S are respectively O(nlogn) and O(nlognλ2(n,QRn)).

One generalization of the stock problem is d-Multiple Stocks Single Transaction, for d1, where we want to find maxi<jAjAi in a d-dimensional array A. Here, by definition, i<j when ik<jk, for 1kd. Our quantum algorithm easily generalizes to that problem.

Theorem 2.

For every d1, the quantum query complexity of d-MSST is O((nlogn)d/2) and its time complexity is

O((nlogn)d/2min{logd+1n+QRnd,log1+d/2(n)loglogn+logd/2(n)loglognQRnd}).

In the k-Increasing Subsequence problem, we would like to decide if, in an array of integers, there is a subsequence of k increasing numbers. As discussed in [13], this is the natural parametrization of the classically well-studied Longest Increasing Subsequence problem, closely related to patience sorting. There are O(nlogn) query classical dynamic programming algorithms solving Longest Increasing Subsequence, and it is easy to show an Ω(n) quantum query lower bound for it. This implies that no substantial quantum improvement can be obtained for k-Increasing Subsequence when k is unbounded, and makes the case of constant k an interesting research question. In [13] an O(nlog3(k1)n) quantum query algorithm was obtained for k-Increasing Subsequence, and we improve this result by a factor of O(logk1n) and implement it time-efficiently. It turns out that a very similar quantum algorithm can solve the k-Signed Sum problem with the same complexity. In this problem, given an array of integers and a sign pattern ε{1,1}k, we want to maximize the signed sum m=1kεmAim, for k indices satisfying i1<i2<<ik.

Theorem 3.

There are quantum algorithms that solve k-Increasing Subsequence and k-Signed Sum with O(nlogk1n) queries. The time complexity of the algorithms is O(nlogk1nλk(n,QRn)).

The problems above have simple create steps. We also consider problems with simple complete steps, and where the main work lies instead in the create step. One interesting example of this is the Longest Distinct Substring (LDS) problem. Given a string aΣn over an alphabet Σ, this problem is to find the longest contiguous substring aiai+1aj where all letters are unique. The famous Element Distinctness problem is a special case of Longest Distinct Substring where the task is to determine if the length of a longest distinct substring is equal to the length of a itself. Ambainis [5] famously gave a quantum walk algorithm showing the time complexity of element distinctness is O~(n2/3), which is tight [2]. We apply our divide and conquer theorem, (Theorem 8), in conjunction with a novel classical divide and conquer algorithm for LDS, to show that a quantum algorithm can solve LDS in time O~(n2/3QWO(n)). Thus, up to logarithmic factors, finding the longest distinct substring has the same quantum time complexity as element distinctness.

Theorem 4.

There is a quantum algorithm that solves LDS in time O~(n2/3)QWO(n) and a quantum algorithm that solves LDS with O(n2/3log(n)loglog(n)) queries.

Another example with a simple complete step is the Klee’s Measure problem from computational geometry, which asks to compute the volume of the union of axis-parallel hyperrectangles in d-dimensional real space. In the special case of the Klee’s Coverage problem, the question is to decide if the union of the hyperrectangles covers a given base hyperrectangle. In 2-dimensions, the classical complexity of the Klee’s Measure problem is O(nlogn) [26], and for any constant d3, Chan [12] has designed an O(nd/2) time classical algorithm for it. We give a quantum algorithm for Klee’s Coverage that achieves almost quadratic speedup over the classical divide and conquer algorithm of Chan [12], when d8.

Theorem 5.

For every constant ε>0, the quantum time complexity of the Klee’s Coverage problem is O(nd/4+εQWN(n)) when d8, and is O(n2QWN(n)) for 5d7, where N(n)=O(nd/2+ε).

Perhaps not surprisingly, our results have some consequences for fine-grained complexity, in particular for the class 𝐀𝐏𝐒𝐏 of problems that are solvable in time O~(n3) on a classical computer and are sub-n3 equivalent to the All-pairs Shortest Paths problem in the sense that either all of them or none of them admit an O(n3ε) algorithm, for some constant ε>0. 𝐀𝐏𝐒𝐏 is one of the richest classes in fine-grained complexity theory [32, 31] and, in particular, contains various path, matrix, and triangle problems.

Quantum fine-grained complexity is a relatively new research area [1, 11, 10] where one possible direction is to study the quantum complexity of problems in the same classical fine-grained equivalence class. Indeed, the work [6] specifically considered 𝐀𝐏𝐒𝐏. Of course, there is no guarantee that classically equivalent problems remain equivalent in the quantum model of computing, and this is indeed the case for 𝐀𝐏𝐒𝐏. All problems in the class receive some quantum speedup, but the degree of speedup can differ from problem to problem. It turns out that many of the problems in 𝐀𝐏𝐒𝐏 can be solved either in time O~(n5/2) or in time O~(n3/2) by simple quantum algorithms and, concretely, All-pairs Shortest Paths falls in the former category. We consider the quantum complexity of two problems from the class 𝐀𝐏𝐒𝐏: Maximum 4-Combination and Maximum Submatrix, both of which take an n×n matrix B as input. We want to compute, for the former, the maximum of Bik+BjBiBjk and, for the latter, the maximum of iuj,kvBuv, under the conditions 1ijn and 1kn. Our quantum algorithm for Maximum 4-Combination uses the quantum divide and conquer method designed for Single Stock Single Transaction.

Theorem 6.

The quantum time complexity of Maximum Submatrix is O(n2logn) and its query complexity is Ω(n2). The quantum time complexity of  Maximum 4-Combination is O(n3/2log5/2(n)).

1.2 Our techniques

As mentioned, our techniques all suppose that the combine step of the divide and conquer is search or minimization and, moreover, the complete or the create steps (or both) are relatively simple. We now describe in more detail how we are able to exploit these properties.

Search or minimization combine step.

The key technical tool we will use repeatedly is based on a relatively old result of Høyer, Mosca and de Wolf [23] (see Fact 1 in Appendix A). Their result is stated for query complexity and essentially says that if, for J boolean functions f1,,fJ:{0,1}n{0,1} there exists a quantum algorithm F that on input |j|x correctly computes fj(x) with probability at least 8/10, then there exists a quantum algorithm which uses O(J) repetitions of F and with probability at least 9/10 finds a marked index, that is 1jJ such that fj(x)=1, if there is one. The main point here is that the number of repetitions is of the same order of magnitude as one would need when F does the computation without error. We analyze the time complexity of the above algorithm and show in Corollary 9 that it is O(J(logJ+τ)), where τ is the time complexity of F. A similar result was also known for the query complexity of finding the index of a minimum element (see Fact 2), and we obtain the analogous result for the time complexity in Corollary 10. In the remaining part of the section, while we only speak about minimization algorithms, everything is valid for search problems as well.

What can we say about the time complexity of F if, for every 1jJ, we have at our disposal an algorithm Aj of known complexity computing fj(x)? Let us call these base algorithms, and for the simplicity of discussion let us suppose that the time complexity of every base algorithm is S+qQRn, where S is the total number of one and two-qubit gates and J,S,q depend on n. If there is no particular relation between the J base algorithms (that is, they can be very different), we do not have a particularly clever implementation of F. One possibility is to compose the quantum circuits to compute them, where the non-query gates of Aj are controlled by j. The query gates can be executed without control, giving an overall complexity of F of O(JS+qQRn), and yielding a minimization algorithm of complexity O(J(JS+qQRn)). Another trivial way to solve the minimization problem is to reduce the error of each base algorithm via logJ repetitions and then classically compute the minimum. The complexities of these approaches are stated in Lemma 11.

However, there is one situation where we can do much better, and this is exactly the case of recursive algorithms such as divide and conquer. In this case, the base algorithms correspond to the recursive calls and are therefore the same by definition. Thus, for implementing F there is no need to use controlled operations or to repeat the base algorithms, provided that we are able to determine, for every j, the memory indices where the 𝖰𝖱𝖠𝖬 gates for Aj are executed (the “index problem”). There are two broad cases we consider, corresponding to simple create and simple complete steps:

Simple create step.

In some cases, such as in the Single Stock Single Transaction problem, the create step is independent of the input. Suppose that the input length is a power of 2. If we unfold the successive recursive steps for this problem, then it is easy to see that, for every input A of length n, there exists t[logn], such that if we partition [n] into 2t consecutive intervals of length n/2t then one of these intervals C contains both i and j, with i<j, such that AjAi is an optimal solution. Moreover, i is in the left half C, and j is in the right half Cr of C, and therefore under this assumption they can be found easily in time n/2t(logn+QRn).

Now the main point is that, for a given t, we don’t know which interval C contains the solution, but to find this good interval we can use quantum maximum finding with an erroneous oracle. These 2t intervals are consecutive and therefore the elements in all intervals can be indexed uniformly, once we settle the first t bits specific to each interval. For every t, this results in a uniform cost n(logn+QRn). After this, we still have to search over the logn possible values of t, again using Corollary 10. This time there are additional costs for implementing F, captured in Lemma 11, because the above procedures are quite different for different values of t. However, as the search is only over a domain of logarithmic size the additional cost is not substantial.

We call the resulting divide and conquer method bottom-up since the method actually completely eliminates the recursive calls, and we give a general statement about this approach in Theorem 12. Avoiding recursion is possible because we know the subproblems in advance, as they are independent of the input. Moreover, under the condition that the solution is contained in some interval C, in our case the additional information that i is in C and j is in Cr makes the solution easier. This, of course, isn’t always the case. Consider the element distinctness problem on an interval of size n. The additional knowledge that the two colliding elements are in different halves of the interval does not make the task of finding them easier. But it does help for Single Stock Single Transaction as well as for Longest Increasing Substring, Longest Identical Substring, Longest 202 Substring and d-Multiple Stocks Single Transaction. In fact, to some extent, we can even generalize the method to k-ary relations, for k>2, which is illustrated by our algorithms for k-Increasing Subsequence and k-Signed Sum.

Simple complete step.

In this case, the main work of the algorithm is done in the create step. We give two relatively generic theorems describing situations where the index problem can be handled well.

The first situation concerns constructible instance problems, where the recursive calls are executed on subproblems that are explicitly constructed by the create step. Such a create step may be expensive to perform and, in particular, all the inputs of the recursive calls (which we call constitutive strings, and which are not necessarily substrings or subsequences of the input) have to be written down, likely taking at least linear time. This implies that this approach can only yield nontrivial results for time complexity, but not for query complexity.

Constructible instance problems are specified by two functions h:, m:+. At each level of recursion, from the input a of length n, the h(n) constitutive strings, a(1),ah(n), each of length n/m(n), are constructed. Then, the solution P(a) has a particularly simple form. For disjunctive problems (when the combine step is the OR function), P(a)=ORjh(n)γ(a,j,P(a(j)), where γ:Σn×[h(n)]×{0,1}{0,1} is a function used in the complete step, and depends on the input a, the constitutive string number, and the solution for the subproblem a(j). Minimizing problems (when the combine step is minimization) are defined analogously.

We can suppose that the constitutive strings are written in a way that the indices of the memory used by the J functions calls Aj, for jJ, differ only in the first logJ bits where, for every j, the algorithm Aj has j in binary.

Theorem 7 (Informal).

Let P be a constructible instance (h,m)-disjunctive (respectively (h,m)-minimizing) problem. Suppose that

  • h(n) and m(n) can be computed by classical algorithms in time O(V(n));

  • there is a classical algorithm that computes the constitutive strings a(1),,a(h(n)) in time O(S(n));

  • the computation of γ(a,j,P(a(j))) can be done by a quantum algorithm in time O(G(n)QWN) and with error at most 1/10.

Then, there exists a quantum divide and conquer algorithm 𝒜 which on input α, computes P(α) with probability at least 9/10 and has a running time T¯ that satisfies the recurrence relation

T¯(n)ch(n)(T¯(n/m(n))+G(n)QWN+logh(n))+O(S(n)QWN+V(n)),

for some constant c>0, where N is the total amount of quantum memory required, and which can be calculated by a recursive equation.

An application of this result is the quantum algorithm for Klee’s Coverage  where the create step requires quadratic time. However, in high dimensions, the time of the homogeneous recursion, which doesn’t include the create step, is much larger and therefore we are able to achieve an almost quadratic speed up over the classical algorithm.

The second situation concerns t-decomposable instance problems, where the recursive calls are made on subsequences of the input. As for constructible instance problems, each recursive call involves determining h(n) constitutive strings, each of length n/m(n). However, in this case, the create step does not need to create the constitutive strings. Rather, the constitutive strings are required to be the concatenation of t substrings of the original input string α, where t is a constant. Then, the work during the create step is to determine the indices that delimit the constitutive strings in the input. We call this set of indices a t-description of the constitutive string and, in principle, computing this can take much less than linear time.

Theorem 8 (Informal).

Let P be a t-decomposable instance (h,m)-disjunctive (respectively (h,m)-minimizing) problem. Let the input α to the problem have length n. Suppose that

  • h(n) and m(n) can be computed by classical algorithms in time O(V(n));

  • there is a quantum algorithm that computes the t-description of constitutive strings in time O(D(n)QWn), and with probability of error at most 1/10;

  • the completion function γ can be done by a quantum algorithm in time O(G(n)QWn), with error at most 1/10.

Then, in the 𝖰𝖱𝖠𝖬 model, there exists a quantum divide and conquer algorithm 𝒜 which computes the problem P with probability at least 8/10, and has running time given by the recurrence relation

T¯(n,n)ch(n)(T¯(n,n/m(n))+G(n)QRn+logh(n))+O(D(n)QRn+V(n)).

An analogous result holds in the 𝖰𝖱𝖠𝖦 model.

As an application of this, by identifying a problem, that we call Bipartite Longest Distinct Substring, as a t-decomposable instance problem whose create and complete functions can be computed in time O~(n2/3)QWO(n), we are able to give a quantum algorithm for solving the Longest Distinct Substring problem in time O~(n2/3)QWO(n).

1.3 Previous work

Recently, several quantum divide and conquer algorithms were presented for various string problems. In the first of these papers, Akmal and Jin [3] considered the k-Length Minimal Substring problem for kn/2, where given a string a of length n over some finite alphabet with a total order, the output is a substring v of a of length k such that for every substring w of a of length k, we have vw, for lexicographic ordering among strings. In the decision version of the problem, the input also includes a string v of length k and the question is whether v is lexicographically smallest among the k-length substrings of a.

The algorithm in [3] works in time n2O(log2/3n), and the high-level structure of the proof goes along the lines of our Theorem 8 for t-decomposable instance minimizing problems, but without involving our Corollary 10 to deal efficiently with the errors of the recursive calls. The combinatorial contents of the proof, however, are quite different. In [3] it is also shown that the problems Minimal String Rotation and Minimal Suffix are easily reducible to k-Length Minimal Substring and therefore have the same quantum time complexity upper bound. In the former problem, one is looking for j[n] such that a[j:n]a[1:j1]a[i:n]a[1:i1], for all i[n], while in the latter problem one looks for j[n] such that a[j:n]<a[i:n], for all ij. The decision versions of these problems, when j is also given in the input, are defined naturally.

In the query complexity model, two papers improved on these results. Childs et al. in  [13] showed that the decision versions of the above problems can be solved in O(nlog5/2n) queries. For Minimal String Rotation Wang [29] improved this to n2O(logn), and for the decision version of the problem further improved this to O(nlog3/2nloglogn). Interestingly, Wang uses Fact 2 on bounded-error oracles in his argument, but the paper does not deal with time complexity.

The result of Childs et al. above was part of a powerful and general framework in the query complexity model for quantum divide and conquer algorithms computing boolean functions. Their framework includes, for example, the case where the complete step is computed by an AND-OR formula in the recursive calls and some auxiliary boolean functions. Besides the problems from the previous paragraph, it is also applied to give algorithms for k-Increasing Subsequence and for k-Common Subsequence where one has to decide whether two strings share a common subsequence of length k. This framework makes use of specific properties of the query model (for example, the equality of the query complexity and the adversary bound), and it is unlikely that it can directly yield results for time complexity. With respect to this framework ours has the following advantages:

  • It deals with time complexity and not only with query complexity.

  • As a consequence, it can also deal with problems of super-linear complexity.

  • It can handle minimization problems and not just boolean functions.

Finally we mention that for the k-Increasing Subsequence problem we improve their query complexity result of O(nlog3(k1)/2n) to O(nlog(k1)/2n).

In independent work, Jeffery and Pass also give a time-efficient quantum algorithm for divide and conquer [24, Theorem 4.13]. Their theorem is incomparable with our results. They allow a symmetric Boolean formula as the combination function, while we consider the combination function to be OR or maximization. Another difference surrounds the flexibility of the create step. They require the create function to work in unit time. Our theorems build the complexity of the create function into the recurrence for the running time, and we allow the create function to either explicitly construct the input to the subproblems (Theorem 7) or reference the input to the subproblems via the original input (Theorem 8).

References

  • [1] Scott Aaronson, Nai-Hui Chia, Han-Hsuan Lin, Chunhao Wang, and Ruizhe Zhang. On the quantum complexity of closest pair and related problems. In Proceedings of the 35th Computational Complexity Conference (CCC), pages 16:1–16:43, 2020. doi:10.4230/LIPICS.CCC.2020.16.
  • [2] Scott Aaronson and Yaoyun Shi. Quantum lower bounds for the collision and the element distinctness problems. Journal of the ACM (JACM), 51(4):595–605, 2004. doi:10.1145/1008731.1008735.
  • [3] Shyan Akmal and Ce Jin. Near-optimal quantum algorithms for string problems. In Joseph (Seffi) Naor and Niv Buchbinder, editors, Proceedings of the 2022 ACM-SIAM Symposium on Discrete Algorithms, SODA 2022, Virtual Conference / Alexandria, VA, USA, January 9 - 12, 2022, pages 2791–2832. SIAM, 2022. doi:10.1137/1.9781611977073.109.
  • [4] Jonathan Allcock, Jinge Bao, Aleksandrs Belovs, Troy Lee, and Miklos Santha. On the quantum time complexity of divide and conquer. arXiv preprint arXiv:2311.16401, 2023. doi:10.48550/arXiv.2311.16401.
  • [5] Andris Ambainis. Quantum walk algorithm for element distinctness. SIAM Journal on Computing, 37(1):210–239, 2007. doi:10.1137/S0097539705447311.
  • [6] Andris Ambainis, Harry Buhrman, Koen Leijnse, Subhasree Patro, and Florian Speelman. Matching triangles and triangle collection: Hardness based on a weak quantum conjecture. arXiv preprint arXiv:2207.11068, 2022. doi:10.48550/arXiv.2207.11068.
  • [7] Srinivasan Arunachalam, Vlad Gheorghiu, Tomas Jochym-O’Connor, Michele Mosca, and Priyaa Varshinee Srinivasan. On the robustness of bucket brigade quantum RAM. In Proceedings of the 10th Conference on the Theory of Quantum Computation, Communication and Cryptography (TQC), pages 226–244, 2015. doi:10.4230/LIPICS.TQC.2015.226.
  • [8] Arturs Backurs, Nishanth Dikkala, and Christos Tzamos. Tight hardness results for maximum weight rectangles. In Proceedings of the 43rd International Colloquium on Automata, Languages, and Programming (ICALP), pages 81:1–81:13, 2016. doi:10.4230/LIPIcs.ICALP.2016.81.
  • [9] Aleksandrs Belovs, Stacey Jeffery, and Duyal Yolcu. Taming quantum time complexity. Quantum, 8:1444, 2024. doi:10.22331/Q-2024-08-23-1444.
  • [10] Harry Buhrman, Bruno Loff, Subhasree Patro, and Florian Speelman. Limits of quantum speed-ups for computational geometry and other problems: Fine-grained complexity via quantum walks. In Proceedings of the 13th Innovations in Theoretical Computer Science Conference (ITCS), pages 31:1–31:12, 2022. doi:10.4230/LIPICS.ITCS.2022.31.
  • [11] Harry Buhrman, Subhasree Patro, and Florian Speelman. A framework of quantum strong exponential-time hypotheses. In Proceedings of the 38th International Symposium on Theoretical Aspects of Computer Science (STACS), pages 19:1–19:19, 2021. doi:10.4230/LIPICS.STACS.2021.19.
  • [12] Timothy M. Chan. Klee’s measure problem made easy. In Proceedings of the 54th Annual IEEE Symposium on Foundations of Computer Science (FOCS), pages 410–419, 2013. doi:10.1109/FOCS.2013.51.
  • [13] Andrew Childs, Robin Kothari, Matt Kovacs-Deak, Aarthi Sundaram, and Daochen Wang. Quantum divide and conquer. ACM Transactions on Quantum Computing, 6(2):1–26, 2025.
  • [14] James Cooley and John Tukey. An algorithm for the machine calculation of complex fourier series. Mathematics of Computation, 19(90):297–301, 1965.
  • [15] Maxime Crochemore and Ely Porat. Computing a longest increasing subsequence of length k in time O(nloglogk). In Erol Gelenbe, Samson Abramsky, and Vladimiro Sassone, editors, Visions of Computer Science - BCS International Academic Conference, Imperial College, London, UK, 22-24 September 2008, pages 69–74. British Computer Society, 2008. URL: http://www.bcs.org/server.php?show=ConWebDoc.22851.
  • [16] Christoph Dürr and Peter Høyer. A quantum algorithm for finding the minimum. arXiv preprint quant-ph/9607014, 1996.
  • [17] Carl Friedrich Gauss. Theoria interpolationis methodo nova tractata. Carl Friedrich Gauss Werke, Königlichen Gesellschaft der Wissenschaften: Göttingen, 3:265–327, 1876.
  • [18] Vittorio Giovannetti, Seth Lloyd, and Lorenzo Maccone. Architectures for a quantum random access memory. Physical Review A, 78(5), 2008. doi:10.1103/physreva.78.052310.
  • [19] Herman Goldstone and John von Neumann. Planning and coding of problems for an electronic computing instrument. IAS Princeton, 2(2):49–68, 1947.
  • [20] Lov K Grover. A fast quantum mechanical algorithm for database search. In Proceedings of the 28th annual ACM symposium on Theory of computing (STOC), pages 212–219, 1996. doi:10.1145/237814.237866.
  • [21] Michael Heideman, Don Johnson, and Sidney Burrus. Gauss and the history of the fast fourier transform. IEEE ASSP Magazine, 1(4):14–21, 1984. doi:10.1109/MASSP.1984.1162257.
  • [22] Tony Hoare. Quicksort. Comput. J., 5(1):10–15, 1962. doi:10.1093/comjnl/5.1.10.
  • [23] Peter Høyer, Michele Mosca, and Ronald de Wolf. Quantum search on bounded-error inputs. In Proceedings of the 30th International Colloquium on Automata, Languages and Programming (ICALP), pages 291–299, 2003. doi:10.1007/3-540-45061-0_25.
  • [24] Stacey Jeffery and Galina Pass. Multidimensional quantum walks, recursion, and quantum divide & conquer. CoRR, 2023. arXiv:2401.08355.
  • [25] Anatoly Karatsuba and Yuri Ofman. Multiplication of many-digital numbers by automatic computers (in russian). Doklady Akademii Nauk SSSR, 145(2):293–294, 1962.
  • [26] Victor Klee. Can the measure of 1n[ai,bi] be computed in less than O(nlogn) steps? American Mathematical Monthly, 84(4):284–285, 1977.
  • [27] Bernhard Korte and László Lovász. Greedoids - a structural framework for the greedy algorithm. In WILLIAM R. PULLEYBLANK, editor, Progress in Combinatorial Optimization, pages 221–243. Academic Press, 1984. doi:10.1016/B978-0-12-566780-7.50019-2.
  • [28] Volker Strassen. Gaussian elimination is not optimal. Numerische Mathematik, 13(4):354–356, 1969. doi:10.1007/BF02165411.
  • [29] Qisheng Wang. A note on quantum divide and conquer for minimal string rotation. Theoretical Computer Science, page 115120, 2025. doi:10.1016/J.TCS.2025.115120.
  • [30] Qisheng Wang and Mingsheng Ying. Quantum algorithm for lexicographically minimal string rotation. Theory of Computing Systems, 68(1):29–74, 2024. doi:10.1007/S00224-023-10146-8.
  • [31] Virginia Vassilevska Williams. On some fine-grained questions in algorithms and complexity. In Proceedings of the International Congress of Mathematicians (ICM), pages 3447–3487, 2019.
  • [32] Virginia Vassilevska Williams and R. Ryan Williams. Subcubic equivalences between path, matrix, and triangle problems. J. ACM, 65(5):27:1–27:38, 2018. doi:10.1145/3186893.

Additional details and some proofs of results stated in the main text can be found here. Omitted proofs and details of all other claims can be found in the full version of the manuscript.

Appendix A Preliminaries

A.1 Notation

We denote by O~(f(n)) the family of functions of the form f(n)polylog(n). For a positive integer n, we denote by [n] the set {1,,n}. Let Σ be a finite set and a=a1anΣn. We define the length of a as n, and we denote it by |a|. We call ai1ai2aij a subsequence of a, for any 1i1<i2<<ijn. A substring is a subsequence of consecutive symbols, and for 1ijn, we use a[i:j] to denote the substring aiai+1aj of a. If i>j then a[i:j] is the empty string. For two strings a,bΣ we denote the concatenation of a and b by a++b. For n we define Σn=nnΣn. When Σ, we use capital letters A,B,C for elements of Σn or Σn×n, that is, for arrays and matrices. For ease of notation, we often neglect taking floors and ceilings in our computations, however, this never affects the correctness of the asymptotic results.

A.2 Quantum computational models

We use the standard quantum circuit model of all single qubit gates and the two-qubit 𝖢𝖭𝖮𝖳 gate, augmented with random access to quantum memory.

A.2.1 QRAM and QRAG

We will use two quantum memory models. In the more restricted 𝖰𝖱𝖠𝖬 model the memory can only be accessed for reading. For any positive integer N, we define the 𝖰𝖱𝖠𝖬N gate as

𝖰𝖱𝖠𝖬N|i,e,x=|i,exi,x,

where i[N],e,x1,xN{0,1}r. We refer to the three registers involved in a 𝖰𝖱𝖠𝖬N gate as the memory index, the memory output, and the memory content registers. The memory index and output registers can be in superposition, but the memory content register always only contains the input string. The memory content register can only be accessed via the 𝖰𝖱𝖠𝖬N gates and these gates can only applied to the memory registers. In the more general 𝖰𝖱𝖠𝖦 model the memory content register can also be accessed for writing.

To formalize this is, for any positive integer N, we define the 𝖰𝖱𝖠𝖦N gate by

𝖰𝖱𝖠𝖦N|i,e,x=|i,xi,x1,,xi1,e,xi+1,xN,

where i[N] and e,x1,,xN{0,1}r. Similar to the other 𝖰𝖱𝖠𝖬 case, here the memory content register can only be accessed via 𝖰𝖱𝖠𝖦N gates and these gates can only applied to the memory registers. Since writing to memory is permitted, the memory content register can also be in quantum superposition.

In our running time analyses, single and two-qubit gates count as one time step. We will use the parameter QRN (“quantum read") to denote the cost of a 𝖰𝖱𝖠𝖬N gate, and the parameter QWN (“quantum write") to denote the cost of a 𝖰𝖱𝖠𝖦N gate. These models are also adapted to query complexity analyses and we define a query as one application of the 𝖰𝖱𝖠𝖬N or the 𝖰𝖱𝖠𝖦N gate, in the respective model of computation.

A.2.2 Inputs vs. Instances

The parameterization by N of the memory access times QRN and QWN allows for quantum memories of different sizes to be accessed at different rates. We assume that the size N of the memory is fixed during the running of any algorithm, and thus the cost of the memory accesses will remain constant during the algorithm, even when recursive calls are made on shorter and shorter strings. We therefore make a distinction between an instance, which is any string on which the algorithm might be recursively called, and an input, which is the initial string the algorithm is given. We denote the size of the input by n. The size of an instance can be any integer nn.

Consequently, the memory content register will be a sufficiently large function N(n)n of the input size, depending on the problem P we are solving. In the 𝖰𝖱𝖠𝖬 model we choose N(n)=n and suppose that, at the beginning of the computation, the input aΣn is in the memory content register. In the 𝖰𝖱𝖠𝖦 model, the size N(n) of the memory content register can be strictly larger than n and we suppose that, at the beginning of the computation, it contains a𝟎N(n)n, where 𝟎=0r.

Thus, for any problem with input of size n, the cost of quantum read and write operations will be QRN(n) and QWN(n), respectively. According to some proposals [18, 7], QRN(n) and QWN(n) might scale as O(rlogN(n)), where r is the number of bits each memory cell can store. In that case, when N(n) is a polynomial function of n, the cost of the memory access operations would be O(rlog(n)). For both 𝖰𝖱𝖠𝖬 and 𝖰𝖱𝖠𝖦 models, we assume that basic arithmetic operations and comparisons can be performed in the same time as memory access.

For notational simplicity, we will quote all final algorithmic running times in our theorems in terms of n rather than n, i.e., we take the input size to be n in our final results.

A.3 Quantum algorithms

We state here several basic quantum algorithms we will use in the paper. All, except the last result on element distinctness, are in the 𝖰𝖱𝖠𝖬 model. The first two are generalizations of Grover’s search algorithm [20] and quantum minimum finding [16] to cases where the oracle can be erroneous.

Fact 1 (Quantum query search with an erroneous oracle, [23]).

For j[J], let fj:Σn{0,1} be a boolean function. Let F be a quantum algorithm that for every (j,x)[J]×Σn, when |x is given in the quantum memory content register, with q queries computes fj(x) with probability at least 7/10. Then there exists a quantum algorithm that uses O(J) repetitions of F and with probability at least 9/10 finds an index j[J] such that fj(x)=1, if there is one. The query complexity of the algorithm is O(Jq).

Fact 2 (Quantum query minimum finding with erroneous oracle, Lemma 3.4 in[30]).

For j[J], let fj:Σn be a function. Let F be a quantum algorithm that for every (j,x)[J]×Σn, when |x is given in the quantum memory content register, with q queries computes fj(x) with probability at least 7/10. Then there exists a quantum algorithm which uses O(J) repetitions of F and with probability at least 9/10 finds the index j[J] of a minimal element in {f1(x),,fJ(x)}. The query complexity of the algorithm is O(Jq).

In the following corollaries, we extend the above results for time complexity. These will be our main tool for the analysis of quantum divide and conquer algorithms since the results of the recursive calls might also be erroneous. Proofs are given in the full version of the manuscript.

Corollary 9 (Quantum search with an erroneous oracle).

For j[J], let fj:Σn{0,1} be a boolean function. Let F be a quantum algorithm that for every (j,x)[J]×Σn, when |x is given in the quantum memory content register, in time τ computes fj(x) with probability at least 7/10. Then there exists a quantum algorithm which in time O(J(logJ+τ)) with probability at least 9/10 finds an index j[J] such that fj(x)=1, if there is one.

Corollary 10 (Quantum minimum finding with an erroneous oracle).

For j[J], let fj:Σn be a function. Let F be a quantum algorithm that for every (j,x)[J]×Σn, when |x is given in the quantum memory content register, in time τ computes fj(x) with probability at least 7/10. Then there exists a quantum algorithm which in time O(J(logJ+τ)) with probability at least 9/10 finds the index j[J] of a minimal element in {f1(x),,fJ(x)}.

In the applications of Corollary 9 and Corollary 10 it is important to have good bounds on the complexity of F. The following Lemma that we state in the 𝖰𝖱𝖠𝖬 model describes two simple but very generic algorithms for computing F that can be used without any assumption on the functions fj. A similar lemma can be proven in the 𝖰𝖱𝖠𝖦 model.

Lemma 11.

Let J:, and for all j[J(n)], let fj:Σn{0,1}, for all j[J(n)], let fj:Σn. Suppose that for every j[J(n)], fj(x) can be computed with probability at least 9/10 by a circuit Cj having Sj(n) one and two-qubit gates and qj(n) query gates. We set Ssum(n)=j[J]Sj(n),qsum(n)=j[J](n)qj(n), and qmax(n)=maxj[J(n)]qj(n). Then, there exist two quantum algorithms 𝒜1 and 𝒜2 which, with probability at least 9/10, find the index j[J(n)] of a marked or minimal element in {f1(x),,fJ(x)}, respectively. The complexities of the algorithms are as follows:

  1. 1.

    𝒜1 makes O(J(n)qmax(n)) queries and takes time O(J(n)(Ssum(n)+qmax(n)QRn)),

  2. 2.

    𝒜2 makes O(logJ(n)qsum(n)) queries and takes time O(logJ(n)(Ssum(n)+qsum(n)QRn)).

Appendix B Bottom-up divide and conquer

When the create function is trivial then the subproblems that arise in a divide and conquer algorithm are known in advance. In this case, we can directly write an iterative algorithm rather than a recursive one, by sequentially solving the subproblems in an appropriate order.

B.1 Generic bottom-up bound

In the problems we look at in this paper, we are frequently trying to find a substring of a string aΣn which maximizes some function.

To see how the bottom-up approach to such a problem works, consider the endpoints i,j[n] of a substring which maximize the function of interest. When viewed as bit strings of length logn corresponding to the binary representation of i1,j1 respectively, these strings will share a common prefix of length t{0,1,,log(n)1}. This means that i,j are contained in a unique interval of length n/2t of the form {(k1)n/2t+1,,kn/2t}, for some k[2t], such that i is in the left half of this interval, and j is in the right half of this interval.

Thus to solve the original problem it suffices to solve the crossing problem: compute the maximum value P(a,t,k) of the function of interest on substrings contained in an interval {(k1)n/2t+1,,kn/2t} specified by k,t whose left endpoint is in the left half of the interval and the right endpoint is in the right half of the interval. The solution to the original problem is then maxtmax1k2tP(a,t,k).

The next theorem gives an upper bound on the quantum complexity of the bottom-up approach in terms of the quantum complexity of solving the crossing problem P(a,t,k).

Theorem 12.

Let n a power of 2, and T={0,,log(n)1}. Let U=Σn×T×[n], S={(a,t,k)U:k2t}, and P:S. Suppose that, for every tT, there is a quantum algorithm At that for every aΣn,1k2t outputs P(a,t,k) with probability at least 9/10 in time n/2tτ(n,t), and with n/2tσ(n,t) queries, for some functions τ,σ:×+. Then there is a quantum algorithm that computes maxt,1k2tP(a,t,k) and the t,k realizing the maximum with probability at least 9/10 in time

O(nloglog(n)(logn+tTτ(n,t)))

and with O(nloglog(n)tTσ(n,t)) queries.

For a proof of Theorem 12, see the full version of the manuscript. Below, we focus on problems that have a quantum running time around n, for which we give a tailored version of Theorem 12.

Theorem 13.

Let n a power of 2, and T={0,,log(n)1}. Let U=Σn×T×[n], S={(a,t,k)U:k2t} and P:S. Suppose that, for every tT, there is a quantum algorithm At that for every aΣn,1k2t outputs P(a,t,k) with probability at least 9/10 in time n/2t(log(n)+QRn), and with O(n/2t) queries. Then there is a quantum algorithm that computes maxtmax1k2tP(a,t,k) and the t,k realizing the maximum with probability at least 9/10 with O(nlog(n)) queries, and a quantum algorithm to do this with running time O(nlog(n)λ2(n,QRn)).

Proof.

For any aΣn,tT, we can compute max1k2tP(a,t,k) with probability at least 9/10 in time O(t2t+n(log(n)+QRn)) by Corollary 10 and with O(n) queries by Fact 2. To compute maxtmax1k2tP(a,t,k) we use Lemma 11. The first item of the lemma gives an algorithm with O(nlogn) queries and running time O(nlog(n)(log2(n)+QRn)). The second item of the lemma gives an algorithm with running time O(nloglog(n)(log2(n)+log(n)QRn)). Taking the minimum of the two options for the time complexity gives the claimed bound of O(nlog(n)λ2(n,QRn)).

B.2 Applications

We now prove Theorem 1 from the main text.

Theorem (Theorem 1 restated).

The quantum query and time complexities of the problems SSST, LISst, LSIC and L202S are respectively O(nlogn) and O(nlognλ2(n,QRn)).

Proof.

Here we prove the theorem for SSST. The remaining cases are dealt with in the full version of the manuscript.

Let n be a power of 2, and for t{0,,log(n)1},1k2t define Cn,t,k={(k1)n/2t+1,,kn/2t}. Note that Cn,t,k=Cn,t+1,2k1Cn,t+1,2k. Let a be an array of integers of size n. Define the problem P(a,t,k) to be

P(a,t,k)=maxiCn,t+1,2k1jCn,t+1,2ka[j]a[i].

For any i<j[n] there is a t,k such that iCn,t+1,2k1 and jCn,t+1,2k. Thus

maxi<ja[j]a[i]=maxtmax1k2tP(a,t,k).

By the quantum minimum finding algorithm [16] we can compute P(a,t,k) with O(n/2t) queries and in time O(n/2t(logn+QRn/2t)). Thus by Theorem 13 there is a quantum algorithm to compute maxtmax1k2tP(a,t,k) and the t,k realizing this value with probability at least 9/10 using O(nlog(n)) queries and a quantum algorithm to do this with time O(nlog(n)λ2(n,QRn)). After we find the t,k realizing the maximum we can again solve P(a,t,k) to find argmaxi<ja[j]a[i] and output these values.

We now prove by induction that there is a quantum algorithm for any n with the desired complexity. The base case is n=2 which is a power of 2 and so done. Now we design an algorithm for an input of a size 2m<n<2m+1 assuming we have an algorithm of the desired complexity for inputs of size at most 2m. There are three choices for argmaxi<ja[j]a[i]: either 1i,j2m, 2m<i,jn, or i2m,j>2m. The first two cases can be solved by the inductive hypothesis, considering a[1:2m] and a[2m+1:n], respectively. For the third case, we can pad a to an array a of size 2m+1 by adding entries to the end and then solve the problem P(a,0,1). We then take the maximum of the three cases. The running time is dominated by the first two cases and so is as desired.

B.3 Generalizations

There are several interesting generalizations of the paradigmatic SSST problem, including d-Multiple Stocks Single Transaction  (d-MSST),k-Increasing Subsequence, k-Signed Sum, k-Single Stock Multiple Transactions and Maximum 4-Combination. Details of these are given in the full version of the manuscript.

Appendix C Disjunctive and minimizing problems

We now turn to applications of Corollary 9 and Corollary 10 to design and analyze quantum divide and conquer algorithms. It turns out that we can do that for problems whose complete step is simple, and whose combine step is either the OR function or minimization. These problems are easily amenable to recursively applying Grover search or minimization on subproblems and therefore to quantum divide and conquer algorithms. However, let us emphasize that their create step can be rather complex.

These problems will be characterized by two functions, h: and m:+. In the divide and conquer algorithm an instance of length n will be divided into h(n) instances of size n/m(n)<n. We call an integer n small for m(n) if n/m(n)n, otherwise n is large for m(n). A string aΣ is called small if |a| is small. These strings correspond to the base cases of the problem, and the other strings are called large.

We will consider two different classes of disjunctive and minimizing problems depending on how the instances of the subproblems are presented during the recursive calls. In the class of constructible instance problems, the instances will be computed and written explicitly to the quantum memory. In the class of t-decomposable instance problems, all recursive calls will be made on subsequences of the original input string and therefore can be described potentially more succinctly by a sufficient number of memory indices.

C.1 Constructible instance problems

In constructible instance problems, the strings on which the recursive calls are made have to be computed explicitly, and therefore the definition of the problem on an instance doesn’t make reference to the initial input. On the other hand, the definition involves the length of the initial input which determines the size of the quantum memory and the cost of all 𝖰𝖱𝖠𝖬 or 𝖰𝖱𝖠𝖦 operations made during the algorithm.

Let h: and m:+. We say that P:n({n}×Σn){0,1} is a constructible instance (h,m)-disjunctive problem if:

  1. 1.

    There are only a constant number of small integers for m(n).

  2. 2.

    There exists a completion function γ:0<nn({n}×Σn×[h(n)]×{0,1}){0,1} such that, for every n, for every large nn, and for every aΣn, there exist strings a(1),,a(h(n)), with |a(1)|==|a(h(n))|=n/m(n), such that

    P(n,a)=ORj[h(n)]γ(n,a,j,P(n,a(j)))

Constructible instance (h,m)-minimizing problems P:n({n}×Σn) are defined similarly, except with γ defined as γ:0<nn({n}×Σn×[h(n)]×)) and P(n,a)=minj[h(n)]γ(n,a,j,P(n,a(j))).

For j[h(n)], we call a(j) the jth constitutive string of a. For every n, for a disjunctive problem P, we define Pn:Σn{0,1} by Pn(a)=P(n,a), and similarly for minimizing problems. The above conditions impose constraints on the create, complete and combine step of problems amenable to divide and conquer algorithms.

Theorem (Theorem 7 formal version).

Let P be a constructible instance (h,m)-disjunctive (respectively (h,m)-minimizing) problem. Suppose that h(n) and m(n) can be computed by classical algorithms in time O(V(n)). Let N(n) be defined by the recursive equations N(n)=O(1) when n is small and, when n is large, N(n)=2k, where k is the smallest integer such that 2k>(h(n)+1)max{n,N(n)}.

Fix n as the input size and let QW=QWN(n). Suppose that there is a classical algorithm that for every large nn, for every aΣn, computes the h(n) constitutive strings a(1),,a(h(n)) in time O(S(n)). Finally suppose that the computation of γ(n,a,j,P(n,a(j))) can be done by a quantum algorithm in time O(G(n)QW) and with error at most 1/10.

Then there exists a quantum divide and conquer algorithm 𝒜 which on an input size n and an instance aΣn, written at the beginning of the memory, where nn, computes Pn with probability at least 9/10 and uses a quantum memory of size N(n). Let T¯(n,n) denote the time complexity of the algorithm, maximized over all words in Σn with nn. Then T¯(n,n)=O(logN(n)+QW) when n is small and, when n is large, T¯(n,n) satisfies the recurrence equation

T¯(n,n)ch(n)(T¯(n,n/m(n))+G(n)QW+logh(n))+O(S(n)QW+V(n)),

for some constant c>0.

The following corollary shows that when the completion function is trivial, an almost quadratic time complexity quantum speed-up over classical divide and conquer algorithms can be achieved.

Corollary 14.

Let h and m be constants and let P be a constructible instance (h,m)-disjunctive or (h,m)-minimizing problem. Suppose that there is a classical algorithm that, for every large a of length n, computes the h constitutive strings a(1),,a(h) in time O(S(n)). Finally suppose that the completion function is trivial, meaning that it is the projection to its fourth argument.

Then, there exists a quantum divide and conquer algorithm 𝒜 which for every n, computes Pn with probability at least 9/10 and uses a quantum memory of size N(n). Let T¯(n,n) be the time complexity of the algorithm. Then

T¯(n,n)=O(logN(n)+QWN(n)),

when n is small and, when n is large, T¯(n,n) satisfies the recurrence equation

T¯(n,n)chT¯(n,n/m)+O(S(n)QWN(n)),

for some constant c>0.

C.2 𝒕-decomposable instance problems

In a constructible instance problem, the main difficulty can be in the create step, computing the constitutive strings which may be non-trivially related to the original input string. The situation is different when, for every instance a, the constitutive strings of a are subsequences of the original input string α. We will consider t-decomposable instance problems where, at every level of recursion, every constitutive string is the concatenation of t substrings of the input, for some constant t.

For some integers nn>0, let αΣn and let t>0 be an integer constant. We say that [n]2t is an n-valid t-description if =(b1,e1,,bt,et) with 1b1e1<b2<btetn. We define the size of as s()=i=1t(eibi+1). Let 𝒱(n,t) denote the set of n-valid t-descriptions, and for 0<nn, let 𝒱(n,t,n) denote the set of n-valid t-descriptions of size n. For 𝒱(n,t), where =(b1,e1,,bt,et), we denote by α the string α[b1:e1]++++α[bt:et]. Observe that |α|=s(). Let aΣn, we say that a is t-decomposable in α if there exists 𝒱(n,t,n) such that a=α, and we call a t-description of a in α. We are interested in t-decomposable instance problems, meaning that for every αΣn, for every large t-decomposable subsequence a of α, the constitutive strings of a are all t-decomposable in α.

We now formally define t-decomposable instance problems. Let αΣn be an input. An instance aΣn which is a t-decomposable in α will be specified by an n-valid t-description of a in α of size n. The t-description can be given in some work registers which is distinct from the memory registers. Observe that is an O(logn) string. We will involve in the definition the create functions δ where, for every αΣn, for every 𝒱(n,t,n), and for every j[h(n)], the value of δ(α,,j) is a t-description of the jth constitutive string α(j) of α.

Let h: and m:+ and t>0 an integer constant. We say that P:n(Σn×𝒱(n,t)){0,1} is a t-decomposable instance (h,m)-disjunctive problem if:

  1. 1.

    There are only a constant number of small integers for m(n).

  2. 2.

    There exist two functions

    δ:0<nn(Σn×𝒱(n,t,n)×[h(n)])𝒱(n,t,n/m(n))

    and

    γ:0<nn(Σn×𝒱(n,t,n)×[h(n)]×𝒱(n,t,n/m(n)×{0,1})){0,1}

    such that for every αΣn, for every 𝒱(n,t,n) where n is large,

    P(α,)=ORj[h(n)]γ(α,,j,δ(α,,j),P(α,δ(α,,j))).

We call the functions δ and γ respectively the create and the completion function, and for j[h(n)], we call αδ(α,,j) the jth constitutive string of α. t-decomposable instance (h,m)-minimizing or maximizing problems can similarly be defined.

We now state a formal version of Theorem 8, which stipulates the existence of a quantum divide and conquer algorithm for t-decomposable instance disjunctive or minimizing problems.

Theorem (Theorem 8 formal version).

Let P be a t-decomposable instance (h,m)-disjunctive or minimizing problem. Suppose that h(n) and m(n) can be computed by classical algorithms in time O(V(n)).

Suppose there is a quantum algorithm that, for every input string αΣn given in the quantum memory, for every large n, for every 𝒱(n,t,n), computes δ(α,,j), for all j[h(n)], in time O(D(n)QWM(n)), for some function M. Suppose also that each computation has probability of error at most 1/10.

Let N(n) be defined by the recursive equations N(n)=O(1) when n is small and N(n)=N(n/m(n))+M(n) when n is large. Also define N(n)=n+N(n). Finally suppose that for every input string αΣn, for every large n, for every 𝒱(n,t,n), the computation of the completion function γ can be done by a quantum algorithm in time O(G(n)QWN(n)) and with error at most 1/10.

Then, there exists a quantum divide and conquer algorithm 𝒜 which computes P on t-decomposable instances in α with probability at least 8/10 and uses a quantum memory of size N(n).

Denote by T¯(n,n) its time complexity, maximized over all inputs α of length n and over all t-decomposable instances in α of length n, specified by a t-description in α. Then, for small n, we have

T¯(n,n)=O(logN(n)+QWN(n)).

When n is large, T¯(n,n) satisfies, for some constant c>0, the recurrence

T¯(n,n)ch(n)(T¯(n,n/m(n))+G(n)QWN(n)+logh(n))+O(D(n)QWN(n)+V(n)).
Proof.

See full version of the manuscript, where similar results are stated for the QRAM model, and for query complexity.

Appendix D Longest Distinct Substring

Recall that a substring of α is a subsequence of consecutive symbols. We say that a substring is distinct if no character in the substring appears more than once.

Problem 1 (Longest Distinct Substring).

Let Σ be an alphabet and αΣn be a string. The goal is to output the length of the longest distinct substring of α, denoted LDS(α).

Computing LDS(α) is a maximization problem over all substrings of α and fits into the bottom-up divide and conquer framework of Appendix B. By repeating the last character of α we may assume that its size is a power of 2 without affecting LDS(α). Letting P(α,t,k) be the length of the longest distinct substring of α[(k1)n/2t+1:kn/2t] whose left endpoint is in the left half of this interval and the right endpoint is in the right half of the interval, we see that LDS(α)=maxtmax1k2tP(α,t,k). Our main task is thus to compute P(α,t,k). This will be done with a divide and conquer algorithm with a non-trivial create step. Because of the nature of the recursive calls in the divide and conquer algorithm for P(α,t,k), it is helpful to consider a more general version of the problem which we call Bipartite Longest Distinct Substring (BLDS).

Problem 2 (Bipartite Longest Distinct Substring).

For an n-valid 2-description let (k) refer to the kth element of . Given α and a n-valid 2-description , the goal of the bipartite longest distinct substring problem is to output the length of a longest distinct substring of α[(1):(2)]++α[(3):(4)] that includes at least one of α(2),α(3). We denote this value by BLDS(α,).

In the full version of the manuscript we prove the following theorem.

Theorem 15.

For any constant integer h2, BLDS(α,) is a 2-decomposable instance (h,h)-maximizing problem. When s()=n, the create and completion functions can be computed by a quantum algorithm with oracle access to α in time O~(n2/3)QWO(n) and with O(n2/3log(n)) queries.

We can now apply Theorem 8 to give the following.

Theorem 16.

There is a quantum algorithm that for any n-valid 2-description with s()=n computes BLDS(α,) in time O~(n2/3)QWO(n)+O(nlog(n)) and with O(n2/3log(n)) queries.

Proof.

We prove the time complexity result here and defer the query complexity proof to the full version of the manuscript. For convenience, let f(n)=O~(n2/3)QWO(n) be an upper bound on the time complexity of the create and completion functions from Theorem 15. By Theorem 8 and Theorem 15, the time complexity T¯(n) for BLDS(α,) with s()=n satisfies the following recurrence relation for any h2:

T¯(1) =O(logn+QWO(n))
T¯(n) ch(T¯(n/h)+f(n))+f(n).

By taking h=2c6, the solution to this recurrence becomes O~(n2/3)QWO(n)+O(nlogn).

Finally, we can use the algorithm for BLDS as part of a bottom-up algorithm for LDS.

Theorem 17.

There is a quantum algorithm that solves LDS in time O~(n2/3)QWO(n) and a quantum algorithm that solves LDS with O(n2/3log(n)loglog(n)) queries.

Proof.

We use the bottom-up approach. Let the input be aΣn. We can pad the input by repeating the last character without changing the length of the longest distinct substring. Thus we may assume n is a power of 2 without changing the asymptotic complexity.

Let P(a,t,k) be the length of the longest distinct substring of a contained in the interval {(k1)n/2t+1,,kn/2t}, with the left endpoint in the left half of this interval and right endpoint in the right half of this interval. Letting i1=(k1)n/2t+1,i2=(2k1)n/2t+1,j1=(2k1)n/2t+1+1,j2=kn/2t and =(i1,i2,j1,j2) we see that P(a,t,k)=BLDS(a,). Thus by Theorem 16 there is a quantum algorithm that outputs P(a,t,k) with probability at least 9/10 in time O~(n2/3/22t/3QWO(n)) and with O(n2/3/22t/3log(n/2t) queries. Applying Theorem 12 gives a quantum algorithm for LDS with running time O~(n2/3)QWO(n) and a quantum algorithm with query complexity O(n2/3log(n)loglog(n)).