Efficient Algorithms for Counting Gapped Palindromes

Authors Andrei Popa, Alexandru Popa

Thumbnail PDF


  • Filesize: 0.73 MB
  • 13 pages

Document Identifiers

Author Details

Andrei Popa
  • Department of Computer Science, University of Bucharest, Romania
Alexandru Popa
  • Department of Computer Science, University of Bucharest, Romania

Cite AsGet BibTex

Andrei Popa and Alexandru Popa. Efficient Algorithms for Counting Gapped Palindromes. In 32nd Annual Symposium on Combinatorial Pattern Matching (CPM 2021). Leibniz International Proceedings in Informatics (LIPIcs), Volume 191, pp. 23:1-23:13, Schloss Dagstuhl – Leibniz-Zentrum für Informatik (2021)


A gapped palindrome is a string uvu^{R}, where u^{R} represents the reverse of string u. In this paper we show three efficient algorithms for counting the occurrences of gapped palindromes in a given string S of length N. First, we present a solution in O(N) time for counting all gapped palindromes without additional constraints. Then, in the case where the length of v is constrained to be in an interval [g, G], we show an algorithm with running time O(N log N). Finally, we show an algorithm in O(N log² N) time for a more general case where we count gapped palindromes uvu^{R}, where u^{R} starts at position i with g(i) ≤ v ≤ G(i), for all positions i.

Subject Classification

ACM Subject Classification
  • Theory of computation → Pattern matching
  • pattern matching
  • gapped palindromes
  • suffix tree


  • Access Statistics
  • Total Accesses (updated on a weekly basis)
    PDF Downloads


  1. Georgy Adelson-Velsky and Evgenii Landis. An algorithm for organization of information. Doklady Akademii Nauk SSSR, 146(2):263-266, 1962. Google Scholar
  2. Gerth Stølting Brodal, Rune B Lyngsø, Christian NS Pedersen, and Jens Stoye. Finding maximal pairs with bounded gap. In Annual Symposium on Combinatorial Pattern Matching, pages 134-149. Springer, 1999. Google Scholar
  3. Mark R Brown and Robert E Tarjan. A fast merging algorithm. Journal of the ACM (JACM), 26(2):211-226, 1979. Google Scholar
  4. Marius Dumitran, Paweł Gawrychowski, and Florin Manea. Longest Gapped Repeats and Palindromes. Discrete Mathematics & Theoretical Computer Science, Vol. 19 no. 4, FCT '15, 2017. URL: https://doi.org/10.23638/DMTCS-19-4-4.
  5. Peter M Fenwick. A new data structure for cumulative frequency tables. Software: Practice and experience, 24(3):327-336, 1994. Google Scholar
  6. Richard Groult, Élise Prieur, and Gwénaël Richomme. Counting distinct palindromes in a word in linear time. Information Processing Letters, 110(20):908-912, 2010. Google Scholar
  7. Dan Gusfield. Algorithms on stings, trees, and sequences: Computer science and computational biology. Acm Sigact News, 28(4):41-60, 1997. Google Scholar
  8. Dov Harel and Robert Endre Tarjan. Fast algorithms for finding nearest common ancestors. siam Journal on Computing, 13(2):338-355, 1984. Google Scholar
  9. Roman Kolpakov and Gregory Kucherov. Searching for gapped palindromes. Theoretical Computer Science, 410(51):5365-5373, 2009. Google Scholar
  10. Tomoko Kuroda-Kawaguchi, Helen Skaletsky, Laura G Brown, Patrick J Minx, Holland S Cordum, Robert H Waterston, Richard K Wilson, Sherman Silber, Robert Oates, Steve Rozen, et al. The azfc region of the y chromosome features massive palindromes and uniform recurrent deletions in infertile men. Nature genetics, 29(3):279-286, 2001. Google Scholar
  11. David RF Leach. Long dna palindromes, cruciform structures, genetic instability and secondary structure repair. Bioessays, 16(12):893-900, 1994. Google Scholar
  12. Le Lu, Hui Jia, Peter Dröge, and Jinming Li. The human genome-wide distribution of dna palindromes. Functional & integrative genomics, 7(3):221-227, 2007. Google Scholar
  13. Glenn Manacher. A new linear-time"on-line"algorithm for finding the smallest initial palindrome of a string. Journal of the ACM (JACM), 22(3):346-351, 1975. Google Scholar
  14. Sjoerd Repping, Helen Skaletsky, Julian Lange, Sherman Silber, Fulco van der Veen, Robert D Oates, David C Page, and Steve Rozen. Recombination between palindromes p5 and p1 on the human y chromosome causes massive deletions and spermatogenic failure. The American Journal of Human Genetics, 71(4):906-922, 2002. Google Scholar
  15. Steve Rozen, Helen Skaletsky, Janet D Marszalek, Patrick J Minx, Holland S Cordum, Robert H Waterston, Richard K Wilson, and David C Page. Abundant gene conversion between arms of palindromes in human and ape y chromosomes. Nature, 423(6942):873-876, 2003. Google Scholar
  16. Mikhail Rubinchik and Arseny M Shur. Counting palindromes in substrings. In International Symposium on String Processing and Information Retrieval, pages 290-303. Springer, 2017. Google Scholar
  17. Esko Ukkonen. On-line construction of suffix trees. Algorithmica, 14(3):249-260, 1995. Google Scholar
  18. Peter E Warburton, Joti Giordano, Fanny Cheung, Yefgeniy Gelfand, and Gary Benson. Inverted repeat structure of the human genome: the x-chromosome contains a preponderance of large, highly homologous inverted repeats that contain testes genes. Genome research, 14(10a):1861-1869, 2004. Google Scholar
  19. Peter Weiner. Linear pattern matching algorithms. In 14th Annual Symposium on Switching and Automata Theory (swat 1973), pages 1-11. IEEE, 1973. Google Scholar
  20. DA Wilson and CA Thomas Jr. Palindromes in chromosomes. Journal of molecular biology, 84(1):115-138, 1974. Google Scholar