Optimal Dynamic Strings
Abstract
In this paper we study the fundamental problem of maintaining a dynamic collection of strings under the following operations: concat - concatenates two strings, split - splits a string into two at a given position, compare - finds the lexicographical order (less, equal, greater) between two strings, LCP - calculates the longest common prefix of two strings. We present an efficient data structure for this problem, where an update requires only worst-case time with high probability, with being the total length of all strings in the collection, and a query takes constant worst-case time. On the lower bound side, we prove that even if the only possible query is checking equality of two strings, either updates or queries take amortized time; hence our implementation is optimal. Such operations can be used as a basic building block to solve other string problems. We provide two examples. First, we can augment our data structure to provide pattern matching queries that may locate occurrences of a specified pattern in the strings in our collection in optimal time, at the expense of increasing update time to . Second, we show how to maintain a history of an edited text, processing updates in time, where is the number of edits, and how to support pattern matching queries against the whole history in time. Finally, we note that our data structure can be applied to test dynamic tree isomorphism and to compare strings generated by dynamic straight-line grammars.
Cite
@article{arxiv.1511.02612,
title = {Optimal Dynamic Strings},
author = {Paweł Gawrychowski and Adam Karczmarz and Tomasz Kociumaka and Jakub Łącki and Piotr Sankowski},
journal= {arXiv preprint arXiv:1511.02612},
year = {2016}
}