Abstract

We consider the problem of preprocessing a text TT of length nn and a dictionary D\mathcal{D} in order to be able to efficiently answer queries CountDistinct(i,j)CountDistinct(i,j), that is, given ii and jj return the number of patterns from D\mathcal{D} that occur in the fragment T[i. .j]T[i \mathinner{.\,.} j]. The dictionary is internal in the sense that each pattern in D\mathcal{D} is given as a fragment of TT. This way, the dictionary takes space proportional to the number of patterns d=∣D∣d=|\mathcal{D}| rather than their total length, which could be Θ(n⋅d)Θ(n\cdot d). An O~(n+d)\tilde{\mathcal{O}}(n+d)-size data structure that answers CountDistinct(i,j)CountDistinct(i,j) queries O(log⁡n)\mathcal{O}(\log n)-approximately in O~(1)\tilde{\mathcal{O}}(1) time was recently proposed in a work that introduced internal dictionary matching [ISAAC 2019]. Here we present an O~(n+d)\tilde{\mathcal{O}}(n+d)-size data structure that answers CountDistinct(i,j)CountDistinct(i,j) queries 22-approximately in O~(1)\tilde{\mathcal{O}}(1) time. Using range queries, for any mm, we give an O~(min⁡(nd/m,n2/m2)+d)\tilde{\mathcal{O}}(\min(nd/m,n^2/m^2)+d)-size data structure that answers CountDistinct(i,j)CountDistinct(i,j) queries exactly in O~(m)\tilde{\mathcal{O}}(m) time. We also consider the special case when the dictionary consists of all square factors of the string. We design an O(nlog⁡2n)\mathcal{O}(n \log^2 n)-size data structure that allows us to count distinct squares in a text fragment T[i. .j]T[i \mathinner{.\,.} j] in O(log⁡n)\mathcal{O}(\log n) time.

Explore this paper’s authors, topics and related work.

Building this map preview

BZPEER is loading the nearby papers, people, topics and institutions for this page.

Reviews 0

Write a reviewWrite

No reviews yet.

Discussion 0

Add a commentWrite

No comments yet.