English

Efficient Dynamic Dictionary Matching with DAWGs and AC-automata

Data Structures and Algorithms 2019-02-22 v4

Abstract

The dictionary matching is a task to find all occurrences of patterns in a set DD (called a dictionary) on a text TT. The Aho-Corasick-automaton (AC-automaton) is a data structure which enables us to solve the dictionary matching problem in O(dlogσ)O(d\log\sigma) preprocessing time and O(nlogσ+occ)O(n\log\sigma+occ) matching time, where dd is the total length of the patterns in DD, nn is the length of the text, σ\sigma is the alphabet size, and occocc is the total number of occurrences of all the patterns in the text. The dynamic dictionary matching is a variant where patterns may dynamically be inserted into and deleted from DD. This problem is called semi-dynamic dictionary matching if only insertions are allowed. In this paper, we propose two efficient algorithms. For a pattern of length mm, our first algorithm supports insertions in O(mlogσ+logd/loglogd)O(m\log\sigma+\log d/\log\log d) time and pattern matching in O(nlogσ+occ)O(n\log\sigma+occ) time for the semi-dynamic setting and supports both insertions and deletions in O(σm+logd/loglogd)O(\sigma m+\log d/\log\log d) time and pattern matching in O(n(logd/loglogd+logσ)+occ(logd/loglogd))O(n(\log d/\log\log d+\log\sigma)+occ(\log d/\log\log d)) time for the dynamic setting by some modifications. This algorithm is based on the directed acyclic word graph. Our second algorithm, which is based on the AC-automaton, supports insertions in O(mlogσ+uf+uo)O(m\log \sigma+u_f+u_o) time for the semi-dynamic setting and supports both insertions and deletions in O(σm+uf+uo)O(\sigma m+u_f+u_o) time for the dynamic setting, where ufu_f and uou_o respectively denote the numbers of states in which the failure function and the output function need to be updated. This algorithm performs pattern matching in O(nlogσ+occ)O(n\log\sigma+occ) time for both settings. Our algorithm achieves optimal update time for AC-automaton based methods over constant-size alphabets, since any algorithm which explicitly maintains the AC-automaton requires Ω(m+uf+uo)\Omega(m+u_f+u_o) update time.

Keywords

Cite

@article{arxiv.1710.03395,
  title  = {Efficient Dynamic Dictionary Matching with DAWGs and AC-automata},
  author = {Diptarama Hendrian and Shunsuke Inenaga and Ryo Yoshinaka and Ayumi Shinohara},
  journal= {arXiv preprint arXiv:1710.03395},
  year   = {2019}
}

Comments

20 pages, 4 figures

R2 v1 2026-06-22T22:08:19.903Z