# Quantum Algorithms for the Most Frequently String Search, Intersection of Two String Sequences and Sorting of Strings Problems

• Artem Ilikaev
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 11934)

## Abstract

We study algorithms for solving three problems on strings. The first one is the Most Frequently String Search Problem. The problem is the following. Assume that we have a sequence of n strings of length k. The problem is finding the string that occurs in the sequence most often. We propose a quantum algorithm that has a query complexity $$\tilde{O}(n \sqrt{k})$$. This algorithm shows speed-up comparing with the deterministic algorithm that requires $$\varOmega (nk)$$ queries.

The second one is searching intersection of two sequences of strings. All strings have the same length k. The size of the first set is n and the size of the second set is m. We propose a quantum algorithm that has a query complexity $$\tilde{O}((n+m) \sqrt{k})$$. This algorithm shows speed-up comparing with the deterministic algorithm that requires $$\varOmega ((n+m)k)$$ queries.

The third problem is sorting of n strings of length k. On the one hand, it is known that quantum algorithms cannot sort objects asymptotically faster than classical ones. On the other hand, we focus on sorting strings that are not arbitrary objects. We propose a quantum algorithm that has a query complexity $$O(n (\log n)^2 \sqrt{k})$$. This algorithm shows speed-up comparing with the deterministic algorithm (radix sort) that requires $$\varOmega ((n+d)k)$$ queries, where d is a size of the alphabet.

## Keywords

Quantum computation Quantum models Quantum algorithm Query model String search Sorting

## Notes

### Acknowledgments

This work was supported by Russian Science Foundation Grant 19-71-00149. We thank Aliya Khadieva, Farid Ablayev and Kazan Federal University quantum group for useful discussions.

## References

1. 1.
Aaronson, S., Shi, Y.: Quantum lower bounds for the collision and the element distinctness problems. J. ACM (JACM) 51(4), 595–605 (2004)
2. 2.
3. 3.
Aggarwal, C.C.: Data Streams: Models and Algorithms, vol. 31. Springer, Berlin (2007).
4. 4.
Ambainis, A.: Understanding quantum algorithms via query complexity. arXiv:1712.06349 (2017)
5. 5.
Ambainis, A.: Quantum walk algorithm for element distinctness. In: Proceedings of the 45th Annual IEEE Symposium on Foundations of Computer Science, FOCS 2004, pp. 22–31 (2004)Google Scholar
6. 6.
Ambainis, A.: Quantum walk algorithm for element distinctness. SIAM J. Comput. 37(1), 210–239 (2007)
7. 7.
Becchetti, L., Chatzigiannakis, I., Giannakopoulos, Y.: Streaming techniques and data aggregation in networks of tiny artefacts. Comput. Sci. Rev. 5(1), 27–46 (2011)
8. 8.
Bennett, C.H., Bernstein, E., Brassard, G., Vazirani, U.: Strengths and weaknesses of quantum computing. SIAM J. Comput. 26(5), 1510–1523 (1997)
9. 9.
Black, P.E.: Dictionary of algorithms and data structures. Technical report, NIST (1998)Google Scholar
10. 10.
Boyar, J., Larsen, K.S., Maiti, A.: The frequent items problem in online streaming under various performance measures. Int. J. Found. Comput. Sci. 26(4), 413–439 (2015)
11. 11.
Boyer, M., Brassard, G., Høyer, P., Tapp, A.: Tight bounds on quantum searching. Fortschr. Phys. 46(4–5), 493–505 (1998)
12. 12.
Brass, P.: Advanced data structures, vol. 193. Cambridge University Press, Cambridge (2008)
13. 13.
Cormen, T.H., Leiserson, C.E., Rivest, R.L., Stein, C.: Introduction to Algorithms. McGraw-Hill, New York (2001)
14. 14.
Cormode, G., Hadjieleftheriou, M.: Finding frequent items in data streams. Proc. VLDB Endow. 1(2), 1530–1541 (2008)
15. 15.
De La Briandais, R.: File searching using variable length keys. In: Western Joint Computer Conference, 3–5 March 1959, pp. 295–298. ACM (1959)Google Scholar
16. 16.
De Wolf, R.: Quantum computing and communication complexity (2001)Google Scholar
17. 17.
Grover, L.K.: A fast quantum mechanical algorithm for database search. In: Proceedings of the Twenty-Eighth Annual ACM Symposium on Theory of Computing, pp. 212–219. ACM (1996)Google Scholar
18. 18.
Guibas, L.J., Sedgewick, R.: A dichromatic framework for balanced trees. In: Proceedings of SFCS 1978, pp. 8–21. IEEE (1978)Google Scholar
19. 19.
Høyer, P., Neerbek, J., Shi, Y.: Quantum complexities of ordered searching, sorting, and element distinctness. In: Orejas, F., Spirakis, P.G., van Leeuwen, J. (eds.) ICALP 2001. LNCS, vol. 2076, pp. 346–357. Springer, Heidelberg (2001).
20. 20.
Høyer, P., Neerbek, J., Shi, Y.: Quantum complexities of ordered searching, sorting, and element distinctness. Algorithmica 34(4), 429–448 (2002)
21. 21.
Jordan, S.: Bounded error quantum algorithms zoo. https://math.nist.gov/quantum/zoo
22. 22.
Kravchenko, D., Khadiev, K., Serov, D.: On the quantum and classical complexity of solving subtraction games. In: van Bevern, R., Kucherov, G. (eds.) CSR 2019. LNCS, vol. 11532, pp. 228–236. Springer, Cham (2019).
23. 23.
Khadiev, K., Safina, L.: Quantum algorithm for dynamic programming approach for DAGs. Applications for Zhegalkin polynomial evaluation and some problems on DAGs. In: McQuillan, I., Seki, S. (eds.) UCNC 2019. LNCS, vol. 11493, pp. 150–163. Springer, Cham (2019).
24. 24.
Klauck, H.: Quantum time-space tradeoffs for sorting. In: Proceedings of the Thirty-Fifth Annual ACM Symposium on Theory of Computing, pp. 69–76. ACM (2003)Google Scholar
25. 25.
Knuth, D.: Searching and Sorting, The Art of Computer Programming, vol. 3 (1973)Google Scholar
26. 26.
Kothari, R.: An optimal quantum algorithm for the oracle identification problem. In: 31st International Symposium on Theoretical Aspects of Computer Science, p. 482 (2014)Google Scholar
27. 27.
Lin, C.Y.Y., Lin, H.H.: Upper bounds on quantum query complexity inspired by the Elitzur-Vaidman bomb tester. In: 30th Conference on Computational Complexity (CCC 2015). Schloss Dagstuhl-Leibniz-Zentrum fuer Informatik (2015)Google Scholar
28. 28.
Lin, C.Y.Y., Lin, H.H.: Upper bounds on quantum query complexity inspired by the Elitzur-Vaidman bomb tester. Theory Comput. 12(18), 1–35 (2016)
29. 29.
Long, G.L.: Grover algorithm with zero theoretical failure rate. Phys. Rev. A 64(2), 022307 (2001)
30. 30.
Montanaro, A.: Quantum pattern matching fast on average. Algorithmica 77(1), 16–39 (2017)
31. 31.
Muthukrishnan, S.: Data streams: algorithms and applications. Found. Trends Theor. Comput. Sci. 1(2), 117–236 (2005)
32. 32.
Nielsen, M.A., Chuang, I.L.: Quantum Computation and Quantum Information. Cambridge University Press, Cambridge (2010)
33. 33.
Odeh, A., Abdelfattah, E.: Quantum sort algorithm based on entanglement qubits $$\{$$00, 11$$\}$$. In: 2016 IEEE Long Island Systems, Applications and Technology Conference (LISAT), pp. 1–5. IEEE (2016)Google Scholar
34. 34.
Odeh, A., Elleithy, K., Almasri, M., Alajlan, A.: Sorting N elements using quantum entanglement sets. In: Third International Conference on Innovative Computing Technology (INTECH 2013), pp. 213–216. IEEE (2013)Google Scholar
35. 35.
Ramesh, H., Vinay, V.: String matching in $$o (\sqrt{n}+ \sqrt{m})$$ quantum time. J. Discrete Algorithms 1(1), 103–110 (2003)
36. 36.
Williams, J.W.J.: Algorithm 232 - heapsort. Commun. ACM 7(6), 347–349 (1964)Google Scholar

© Springer Nature Switzerland AG 2019