English

Order-Preserving Squares in Strings

Data Structures and Algorithms 2023-02-03 v1 Formal Languages and Automata Theory

Abstract

An order-preserving square in a string is a fragment of the form uvuv where uvu\neq v and uu is order-isomorphic to vv. We show that a string ww of length nn over an alphabet of size σ\sigma contains O(σn)\mathcal{O}(\sigma n) order-preserving squares that are distinct as words. This improves the upper bound of O(σ2n)\mathcal{O}(\sigma^{2}n) by Kociumaka, Radoszewski, Rytter, and Wale\'n [TCS 2016]. Further, for every σ\sigma and nn we exhibit a string with Ω(σn)\Omega(\sigma n) order-preserving squares that are distinct as words, thus establishing that our upper bound is asymptotically tight. Finally, we design an O(σn)\mathcal{O}(\sigma n) time algorithm that outputs all order-preserving squares that occur in a given string and are distinct as words. By our lower bound, this is optimal in the worst case.

Keywords

Cite

@article{arxiv.2302.00724,
  title  = {Order-Preserving Squares in Strings},
  author = {Paweł Gawrychowski and Samah Ghazawi and Gad M. Landau},
  journal= {arXiv preprint arXiv:2302.00724},
  year   = {2023}
}
R2 v1 2026-06-28T08:29:33.639Z