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 insertions 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|)\) preprocessing 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 (inserting characters to one end of the text), maintaining the same amortized bounds.

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

String Matching with a Dynamic Pattern

  • Bruno Monteiro,
  • Vinicius dos Santos

摘要

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 insertions 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|)\) preprocessing 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 (inserting characters to one end of the text), maintaining the same amortized bounds.