String Matching with a Dynamic Pattern

Fuente: arXiv
Gespeichert in:
Bibliographische Detailangaben
Hauptverfasser: Monteiro, Bruno, Santos, Vinicius dos
Format: Preprint
Veröffentlicht: 2025
Schlagworte:
Online-Zugang:
Tags: Tag hinzufügen
Keine Tags, Fügen Sie den ersten Tag hinzu!
_version_ 1866908406376300544
author Monteiro, Bruno
Santos, Vinicius dos
author_facet Monteiro, Bruno
Santos, Vinicius dos
contents In this work, we tackle a natural variation of the String Matching Problem on the case of a dynamic pattern, that is, given a static text $T$ and a pattern $P$, we want to support character additions and deletions to the pattern, and after each operation compute how many times it occurs in the text. We show a simple and practical algorithm using Suffix Arrays that achieves $\mathcal O(\log |T|)$ update time, after $\mathcal O(|T|)$ preprocess time. We show how to extend our solution to support substring deletion, transposition (moving a substring to another position of the pattern), and copy (copying a substring and pasting it in a specific position), in the same time complexities. Our solution can also be extended to support an online text (adding characters to one end of the text), maintaining the same amortized bounds.
format Preprint
id arxiv_https___arxiv_org_abs_2506_11318
institution arXiv
publishDate 2025
record_format arxiv
spellingShingle String Matching with a Dynamic Pattern
Monteiro, Bruno
Santos, Vinicius dos
Data Structures and Algorithms
Discrete Mathematics
In this work, we tackle a natural variation of the String Matching Problem on the case of a dynamic pattern, that is, given a static text $T$ and a pattern $P$, we want to support character additions and deletions to the pattern, and after each operation compute how many times it occurs in the text. We show a simple and practical algorithm using Suffix Arrays that achieves $\mathcal O(\log |T|)$ update time, after $\mathcal O(|T|)$ preprocess time. We show how to extend our solution to support substring deletion, transposition (moving a substring to another position of the pattern), and copy (copying a substring and pasting it in a specific position), in the same time complexities. Our solution can also be extended to support an online text (adding characters to one end of the text), maintaining the same amortized bounds.
title String Matching with a Dynamic Pattern
topic Data Structures and Algorithms
Discrete Mathematics
url https://arxiv.org/abs/2506.11318