## Abstract

A fundamental concept related to strings is that of repetitions. It has been extensively studied in many versions, from both purely combinatorial and algorithmic angles. One of the most basic questions is how many distinct squares, i.e., distinct strings of the form UU, a string of length n can contain as fragments. It turns out that this is always O(n), and the bound cannot be improved to sublinear in n [Fraenkel and Simpson, JCTA 1998]. Several similar questions about repetitions in strings have been considered, and by now we seem to have a good understanding of their repetitive structure. For higher-dimensional strings, the basic concept of periodicity has been successfully extended and applied to design efficient algorithms – it is inherently more complex than for regular strings. Extending the notion of repetitions and understanding the repetitive structure of higher-dimensional strings is however far from complete. Quartics were introduced by Apostolico and Brimkov [TCS 2000] as analogues of squares in two dimensions. Charalampopoulos, Radoszewski, Rytter, Waleń, and Zuba [ESA 2020] proved that the number of distinct quartics in an n × n 2D string is O(n^{2} log^{2} n) and that they can be computed in O(n^{2} log^{2} n) time. Gawrychowski, Ghazawi, and Landau [SPIRE 2021] constructed an infinite family of n × n 2D strings with Ω(n^{2} log n) distinct quartics. This brings the challenge of determining asymptotically tight bounds. Here, we settle both the combinatorial and the algorithmic aspects of this question: the number of distinct quartics in an n × n 2D string is O(n^{2} log n) and they can be computed in the worst-case optimal O(n^{2} log n) time. As expected, our solution heavily exploits the periodic structure implied by occurrences of quartics. However, the two-dimensional nature of the problem introduces some technical challenges. Somewhat surprisingly, we overcome the final challenge for the combinatorial bound using a result of Marcus and Tardos [JCTA 2004] for permutation avoidance on matrices.

Original language | English |
---|---|

Title of host publication | 51st International Colloquium on Automata, Languages, and Programming, ICALP 2024 |

Editors | Karl Bringmann, Martin Grohe, Gabriele Puppis, Ola Svensson |

Publisher | Schloss Dagstuhl- Leibniz-Zentrum fur Informatik GmbH, Dagstuhl Publishing |

ISBN (Electronic) | 9783959773225 |

DOIs | |

State | Published - Jul 2024 |

Event | 51st International Colloquium on Automata, Languages, and Programming, ICALP 2024 - Tallinn, Estonia Duration: 8 Jul 2024 → 12 Jul 2024 |

### Publication series

Name | Leibniz International Proceedings in Informatics, LIPIcs |
---|---|

Volume | 297 |

ISSN (Print) | 1868-8969 |

### Conference

Conference | 51st International Colloquium on Automata, Languages, and Programming, ICALP 2024 |
---|---|

Country/Territory | Estonia |

City | Tallinn |

Period | 8/07/24 → 12/07/24 |

### Bibliographical note

Publisher Copyright:© Panagiotis Charalampopoulos, Paweł Gawrychowski, and Samah Ghazawi.

## Keywords

- 2D strings
- periodicity
- quartics
- repetitions

## ASJC Scopus subject areas

- Software