On the Quantum Time Complexity of Divide and Conquer
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 -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.
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.
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.
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 -Increasing Subsequence by a logarithmic factor.
Keywords and phrases:
Quantum Computing, Quantum Algorithms, Divide and ConquerCategory:
Track A: Algorithms, Complexity and GamesCopyright and License:
![[Uncaptioned image]](x1.png)
2012 ACM Subject Classification:
Theory of computation Quantum computation theoryFunding:
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 PuppisSeries and Publisher:

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 for a given array . 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 is maximized when is the maximum value in the second half of and is the minimum value in the first half of .
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.
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 , we denote the time required to perform a or query by parameters (quantum reading) and (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
Classical Time | Quantum Time | |||||
Longest Distinct Substring | ||||||
Klee’s Coverage in | [12] | |||||
Single Stock Single Transaction | ||||||
|
|
|||||
Maximum 4-Combination | [8] |
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 , 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 Substring problem (LS) we have to find the longest substring belonging to in a string from . 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 , and they require time . Our algorithms achieve an almost quadratic quantum speed up. For the rest of the paper, for , we define the function
Observe that for we have and for we have
Theorem 1.
The quantum query and time complexities of the problems SSST, LISst, LSIC and LS are respectively and .
One generalization of the stock problem is -Multiple Stocks Single Transaction, for , where we want to find in a -dimensional array . Here, by definition, when , for Our quantum algorithm easily generalizes to that problem.
Theorem 2.
For every , the quantum query complexity of -MSST is and its time complexity is
In the -Increasing Subsequence problem, we would like to decide if, in an array of integers, there is a subsequence of 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 query classical dynamic programming algorithms solving Longest Increasing Subsequence, and it is easy to show an quantum query lower bound for it. This implies that no substantial quantum improvement can be obtained for -Increasing Subsequence when is unbounded, and makes the case of constant an interesting research question. In [13] an quantum query algorithm was obtained for -Increasing Subsequence, and we improve this result by a factor of and implement it time-efficiently. It turns out that a very similar quantum algorithm can solve the -Signed Sum problem with the same complexity. In this problem, given an array of integers and a sign pattern , we want to maximize the signed sum , for indices satisfying .
Theorem 3.
There are quantum algorithms that solve -Increasing Subsequence and -Signed Sum with queries. The time complexity of the algorithms is .
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 over an alphabet , this problem is to find the longest contiguous substring 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 itself. Ambainis [5] famously gave a quantum walk algorithm showing the time complexity of element distinctness is , 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 . 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 and a quantum algorithm that solves LDS with 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 -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 [26], and for any constant , Chan [12] has designed an 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 .
Theorem 5.
For every constant , the quantum time complexity of the Klee’s Coverage problem is when , and is for , where .
Perhaps not surprisingly, our results have some consequences for fine-grained complexity, in particular for the class of problems that are solvable in time on a classical computer and are sub- equivalent to the All-pairs Shortest Paths problem in the sense that either all of them or none of them admit an algorithm, for some constant . 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 or in time 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 matrix as input. We want to compute, for the former, the maximum of and, for the latter, the maximum of , under the conditions and . 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 and its query complexity is The quantum time complexity of Maximum 4-Combination is
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 boolean functions there exists a quantum algorithm that on input correctly computes with probability at least , then there exists a quantum algorithm which uses repetitions of and with probability at least finds a marked index, that is such that , 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 does the computation without error. We analyze the time complexity of the above algorithm and show in Corollary 9 that it is , where is the time complexity of . 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 if, for every , we have at our disposal an algorithm of known complexity computing ? Let us call these base algorithms, and for the simplicity of discussion let us suppose that the time complexity of every base algorithm is , where is the total number of one and two-qubit gates and depend on . If there is no particular relation between the base algorithms (that is, they can be very different), we do not have a particularly clever implementation of . One possibility is to compose the quantum circuits to compute them, where the non-query gates of are controlled by . The query gates can be executed without control, giving an overall complexity of of , and yielding a minimization algorithm of complexity . Another trivial way to solve the minimization problem is to reduce the error of each base algorithm via 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 there is no need to use controlled operations or to repeat the base algorithms, provided that we are able to determine, for every , the memory indices where the gates for 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 . If we unfold the successive recursive steps for this problem, then it is easy to see that, for every input of length , there exists , such that if we partition into consecutive intervals of length then one of these intervals contains both and , with , such that is an optimal solution. Moreover, is in the left half , and is in the right half of , and therefore under this assumption they can be found easily in time .
Now the main point is that, for a given , we don’t know which interval contains the solution, but to find this good interval we can use quantum maximum finding with an erroneous oracle. These intervals are consecutive and therefore the elements in all intervals can be indexed uniformly, once we settle the first bits specific to each interval. For every , this results in a uniform cost . After this, we still have to search over the possible values of , again using Corollary 10. This time there are additional costs for implementing , captured in Lemma 11, because the above procedures are quite different for different values of . 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 , in our case the additional information that is in and is in makes the solution easier. This, of course, isn’t always the case. Consider the element distinctness problem on an interval of size . 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 Substring and -Multiple Stocks Single Transaction. In fact, to some extent, we can even generalize the method to -ary relations, for , which is illustrated by our algorithms for -Increasing Subsequence and -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 , . At each level of recursion, from the input of length , the constitutive strings, , each of length , are constructed. Then, the solution has a particularly simple form. For disjunctive problems (when the combine step is the OR function), , where is a function used in the complete step, and depends on the input , the constitutive string number, and the solution for the subproblem . 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 functions calls , for differ only in the first bits where, for every , the algorithm has in binary.
Theorem 7 (Informal).
Let be a constructible instance -disjunctive (respectively -minimizing) problem. Suppose that
-
and can be computed by classical algorithms in time ;
-
there is a classical algorithm that computes the constitutive strings in time ;
-
the computation of can be done by a quantum algorithm in time and with error at most .
Then, there exists a quantum divide and conquer algorithm which on input , computes with probability at least and has a running time that satisfies the recurrence relation
for some constant , where 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 -decomposable instance problems, where the recursive calls are made on subsequences of the input. As for constructible instance problems, each recursive call involves determining constitutive strings, each of length . 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 substrings of the original input string , where 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 -description of the constitutive string and, in principle, computing this can take much less than linear time.
Theorem 8 (Informal).
Let be a -decomposable instance -disjunctive (respectively -minimizing) problem. Let the input to the problem have length . Suppose that
-
and can be computed by classical algorithms in time ;
-
there is a quantum algorithm that computes the -description of constitutive strings in time , and with probability of error at most ;
-
the completion function can be done by a quantum algorithm in time , with error at most .
Then, in the model, there exists a quantum divide and conquer algorithm which computes the problem with probability at least , and has running time given by the recurrence relation
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 -decomposable instance problem whose create and complete functions can be computed in time , we are able to give a quantum algorithm for solving the Longest Distinct Substring problem in time .
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 -Length Minimal Substring problem for , where given a string of length over some finite alphabet with a total order, the output is a substring of of length such that for every substring of of length , we have , for lexicographic ordering among strings. In the decision version of the problem, the input also includes a string of length and the question is whether is lexicographically smallest among the -length substrings of .
The algorithm in [3] works in time , and the high-level structure of the proof goes along the lines of our Theorem 8 for -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 -Length Minimal Substring and therefore have the same quantum time complexity upper bound. In the former problem, one is looking for such that , for all , while in the latter problem one looks for such that , for all . The decision versions of these problems, when 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 queries. For Minimal String Rotation Wang [29] improved this to , and for the decision version of the problem further improved this to . 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 -Increasing Subsequence and for -Common Subsequence where one has to decide whether two strings share a common subsequence of length . 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 -Increasing Subsequence problem we improve their query complexity result of to .
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 in time . 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 be computed in less than 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 the family of functions of the form . For a positive integer , we denote by the set . Let be a finite set and . We define the length of as , and we denote it by . We call a subsequence of , for any . A substring is a subsequence of consecutive symbols, and for , we use to denote the substring of . If then is the empty string. For two strings we denote the concatenation of and by . For we define . When , we use capital letters for elements of or , 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 , we define the gate as
where . We refer to the three registers involved in a 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 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 , we define the gate by
where and Similar to the other case, here the memory content register can only be accessed via 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 (“quantum read") to denote the cost of a gate, and the parameter (“quantum write") to denote the cost of a gate. These models are also adapted to query complexity analyses and we define a query as one application of the or the gate, in the respective model of computation.
A.2.2 Inputs vs. Instances
The parameterization by of the memory access times and allows for quantum memories of different sizes to be accessed at different rates. We assume that the size 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 . The size of an instance can be any integer .
Consequently, the memory content register will be a sufficiently large function of the input size, depending on the problem we are solving. In the model we choose and suppose that, at the beginning of the computation, the input is in the memory content register. In the model, the size of the memory content register can be strictly larger than and we suppose that, at the beginning of the computation, it contains , where .
Thus, for any problem with input of size , the cost of quantum read and write operations will be and , respectively. According to some proposals [18, 7], and might scale as , where is the number of bits each memory cell can store. In that case, when is a polynomial function of , the cost of the memory access operations would be . 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 rather than , i.e., we take the input size to be 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 , let be a boolean function. Let be a quantum algorithm that for every , when is given in the quantum memory content register, with queries computes with probability at least Then there exists a quantum algorithm that uses repetitions of and with probability at least finds an index such that , if there is one. The query complexity of the algorithm is .
Fact 2 (Quantum query minimum finding with erroneous oracle, Lemma 3.4 in[30]).
For , let be a function. Let be a quantum algorithm that for every , when is given in the quantum memory content register, with queries computes with probability at least Then there exists a quantum algorithm which uses repetitions of and with probability at least finds the index of a minimal element in . The query complexity of the algorithm is .
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 , let be a boolean function. Let be a quantum algorithm that for every , when is given in the quantum memory content register, in time computes with probability at least Then there exists a quantum algorithm which in time with probability at least finds an index such that , if there is one.
Corollary 10 (Quantum minimum finding with an erroneous oracle).
For , let be a function. Let be a quantum algorithm that for every , when is given in the quantum memory content register, in time computes with probability at least Then there exists a quantum algorithm which in time with probability at least finds the index of a minimal element in .
In the applications of Corollary 9 and Corollary 10 it is important to have good bounds on the complexity of . The following Lemma that we state in the model describes two simple but very generic algorithms for computing that can be used without any assumption on the functions . A similar lemma can be proven in the model.
Lemma 11.
Let , and for all , let , for all , let . Suppose that for every , can be computed with probability at least by a circuit having one and two-qubit gates and query gates. We set , and . Then, there exist two quantum algorithms and which, with probability at least , find the index of a marked or minimal element in , respectively. The complexities of the algorithms are as follows:
-
1.
makes queries and takes time ,
-
2.
makes queries and takes time .
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 which maximizes some function.
To see how the bottom-up approach to such a problem works, consider the endpoints of a substring which maximize the function of interest. When viewed as bit strings of length corresponding to the binary representation of respectively, these strings will share a common prefix of length . This means that are contained in a unique interval of length of the form , for some , such that is in the left half of this interval, and 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 of the function of interest on substrings contained in an interval specified by 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 .
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 .
Theorem 12.
Let a power of 2, and . Let , , and . Suppose that, for every , there is a quantum algorithm that for every outputs with probability at least in time , and with queries, for some functions . Then there is a quantum algorithm that computes and the realizing the maximum with probability at least in time
and with 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 , for which we give a tailored version of Theorem 12.
Theorem 13.
Let a power of 2, and . Let , and . Suppose that, for every , there is a quantum algorithm that for every outputs with probability at least in time , and with queries. Then there is a quantum algorithm that computes and the realizing the maximum with probability at least with queries, and a quantum algorithm to do this with running time .
Proof.
For any , we can compute with probability at least in time by Corollary 10 and with queries by Fact 2. To compute we use Lemma 11. The first item of the lemma gives an algorithm with queries and running time . The second item of the lemma gives an algorithm with running time . Taking the minimum of the two options for the time complexity gives the claimed bound of .
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 LS are respectively and .
Proof.
Here we prove the theorem for SSST. The remaining cases are dealt with in the full version of the manuscript.
Let be a power of 2, and for define . Note that . Let be an array of integers of size . Define the problem to be
For any there is a such that and . Thus
By the quantum minimum finding algorithm [16] we can compute with queries and in time . Thus by Theorem 13 there is a quantum algorithm to compute and the realizing this value with probability at least using queries and a quantum algorithm to do this with time . After we find the realizing the maximum we can again solve to find and output these values.
We now prove by induction that there is a quantum algorithm for any with the desired complexity. The base case is which is a power of 2 and so done. Now we design an algorithm for an input of size assuming we have an algorithm of the desired complexity for inputs of size at most . There are three choices for : either , , or . The first two cases can be solved by the inductive hypothesis, considering and , respectively. For the third case, we can pad to an array of size by adding entries to the end and then solve the problem . 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 -Multiple Stocks Single Transaction (-MSST),-Increasing Subsequence, -Signed Sum, -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 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, and . In the divide and conquer algorithm an instance of length will be divided into instances of size . We call an integer small for if otherwise is large for . A string is called small if 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 -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 and . We say that is a constructible instance -disjunctive problem if:
-
1.
There are only a constant number of small integers for .
-
2.
There exists a completion function such that, for every , for every large , and for every , there exist strings , with , such that
Constructible instance -minimizing problems are defined similarly, except with defined as and .
For , we call the th constitutive string of . For every , for a disjunctive problem , we define by , 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 be a constructible instance -disjunctive (respectively -minimizing) problem. Suppose that and can be computed by classical algorithms in time . Let be defined by the recursive equations when is small and, when is large, , where is the smallest integer such that .
Fix as the input size and let . Suppose that there is a classical algorithm that for every large , for every , computes the constitutive strings in time . Finally suppose that the computation of can be done by a quantum algorithm in time and with error at most .
Then there exists a quantum divide and conquer algorithm which on an input size and an instance , written at the beginning of the memory, where , computes with probability at least and uses a quantum memory of size . Let denote the time complexity of the algorithm, maximized over all words in with . Then when is small and, when is large, satisfies the recurrence equation
for some constant .
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 and be constants and let be a constructible instance -disjunctive or -minimizing problem. Suppose that there is a classical algorithm that, for every large of length , computes the constitutive strings in time . 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 , computes with probability at least and uses a quantum memory of size . Let be the time complexity of the algorithm. Then
when is small and, when is large, satisfies the recurrence equation
for some constant .
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 , the constitutive strings of 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 substrings of the input, for some constant .
For some integers let and let be an integer constant. We say that is an -valid -description if with . We define the size of as . Let denote the set of -valid -descriptions, and for , let denote the set of -valid -descriptions of size . For , where we denote by the string . Observe that Let we say that is -decomposable in if there exists such that and we call a -description of in . We are interested in -decomposable instance problems, meaning that for every , for every large -decomposable subsequence of , the constitutive strings of are all -decomposable in .
We now formally define -decomposable instance problems. Let be an input. An instance which is a -decomposable in will be specified by an -valid -description of in of size . The -description can be given in some work registers which is distinct from the memory registers. Observe that is an string. We will involve in the definition the create functions where, for every , for every , and for every , the value of is a -description of the th constitutive string of
Let and and an integer constant. We say that is a -decomposable instance -disjunctive problem if:
-
1.
There are only a constant number of small integers for .
-
2.
There exist two functions
and
such that for every , for every where is large,
We call the functions and respectively the create and the completion function, and for , we call the th constitutive string of . -decomposable instance -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 -decomposable instance disjunctive or minimizing problems.
Theorem (Theorem 8 formal version).
Let be a -decomposable instance -disjunctive or minimizing problem. Suppose that and can be computed by classical algorithms in time .
Suppose there is a quantum algorithm that, for every input string given in the quantum memory, for every large , for every , computes , for all , in time , for some function . Suppose also that each computation has probability of error at most .
Let be defined by the recursive equations when is small and when is large. Also define . Finally suppose that for every input string , for every large , for every , the computation of the completion function can be done by a quantum algorithm in time and with error at most .
Then, there exists a quantum divide and conquer algorithm which computes on -decomposable instances in with probability at least and uses a quantum memory of size .
Denote by its time complexity, maximized over all inputs of length and over all -decomposable instances in of length , specified by a -description in . Then, for small , we have
When is large, satisfies, for some constant , the recurrence
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 be a string. The goal is to output the length of the longest distinct substring of , denoted .
Computing 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 . Letting be the length of the longest distinct substring of 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 . Our main task is thus to compute . 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 , 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 -valid 2-description let refer to the element of . Given and a -valid 2-description , the goal of the bipartite longest distinct substring problem is to output the length of a longest distinct substring of that includes at least one of . We denote this value by .
In the full version of the manuscript we prove the following theorem.
Theorem 15.
For any constant integer , is a 2-decomposable instance -maximizing problem. When , the create and completion functions can be computed by a quantum algorithm with oracle access to in time and with queries.
We can now apply Theorem 8 to give the following.
Theorem 16.
There is a quantum algorithm that for any -valid 2-description with computes in time and with 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 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 for with satisfies the following recurrence relation for any :
By taking , the solution to this recurrence becomes .
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 and a quantum algorithm that solves LDS with queries.
Proof.
We use the bottom-up approach. Let the input be . We can pad the input by repeating the last character without changing the length of the longest distinct substring. Thus we may assume is a power of 2 without changing the asymptotic complexity.
Let be the length of the longest distinct substring of contained in the interval , with the left endpoint in the left half of this interval and right endpoint in the right half of this interval. Letting and we see that . Thus by Theorem 16 there is a quantum algorithm that outputs with probability at least in time and with queries. Applying Theorem 12 gives a quantum algorithm for LDS with running time and a quantum algorithm with query complexity .