We consider the problem of maintaining a collection of strings while efficiently supporting splits and concatenations on them, as well as comparing two substrings, and computing the longest common prefix between two suffixes. This problem can be solved in optimal time O(log N) whp for the updates and O(1) worst-case time for the queries, where N is the total collection size [Gawrychowski et al., SODA 2018]. We present here a much simpler solution based on a forest of enhanced splay trees (FeST), where both the updates and the substring comparison take O(log n) amortized time, n being the sum of the lengths of the strings involved in the operation. The length l of the longest common prefix is computed in O(log n + log l) amortized time. Our query results are correct whp. Our simpler solution enables other more general updates in O(log n) amortized time, such as reversing a substring and/or mapping its symbols. We can also make FeST use compact space, and extend it to regard substrings as circular or as their omega extension. A C++- implementation of our FeST data structure is available at https://github.com/fmasillo/FeST.

A textbook solution for dynamic strings

Lipták, Zsuzsanna
;
2026-01-01

Abstract

We consider the problem of maintaining a collection of strings while efficiently supporting splits and concatenations on them, as well as comparing two substrings, and computing the longest common prefix between two suffixes. This problem can be solved in optimal time O(log N) whp for the updates and O(1) worst-case time for the queries, where N is the total collection size [Gawrychowski et al., SODA 2018]. We present here a much simpler solution based on a forest of enhanced splay trees (FeST), where both the updates and the substring comparison take O(log n) amortized time, n being the sum of the lengths of the strings involved in the operation. The length l of the longest common prefix is computed in O(log n + log l) amortized time. Our query results are correct whp. Our simpler solution enables other more general updates in O(log n) amortized time, such as reversing a substring and/or mapping its symbols. We can also make FeST use compact space, and extend it to regard substrings as circular or as their omega extension. A C++- implementation of our FeST data structure is available at https://github.com/fmasillo/FeST.
2026
Dynamic strings, Binary search trees, Splay trees, Dynamic data structures
File in questo prodotto:
File Dimensione Formato  
1-s2.0-S0304397526000058-main.pdf

accesso aperto

Licenza: Creative commons
Dimensione 2.97 MB
Formato Adobe PDF
2.97 MB Adobe PDF Visualizza/Apri

I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.

Utilizza questo identificativo per citare o creare un link a questo documento: https://hdl.handle.net/11562/1181127
Citazioni
  • ???jsp.display-item.citation.pmc??? ND
  • Scopus ND
  • ???jsp.display-item.citation.isi??? ND
social impact