P. Charalampopoulos, T. Kociumaka, Manal Mohamed, J. Radoszewski, W. Rytter, Juliusz Straszy'nski, Tomasz Wale'n, Wiktor Zuba
{"title":"Counting Distinct Patterns in Internal Dictionary Matching","authors":"P. Charalampopoulos, T. Kociumaka, Manal Mohamed, J. Radoszewski, W. Rytter, Juliusz Straszy'nski, Tomasz Wale'n, Wiktor Zuba","doi":"10.4230/LIPIcs.CPM.2020.8","DOIUrl":null,"url":null,"abstract":"We consider the problem of preprocessing a text $T$ of length $n$ and a dictionary $\\mathcal{D}$ in order to be able to efficiently answer queries $CountDistinct(i,j)$, that is, given $i$ and $j$ return the number of patterns from $\\mathcal{D}$ that occur in the fragment $T[i \\mathinner{.\\,.} j]$. The dictionary is internal in the sense that each pattern in $\\mathcal{D}$ is given as a fragment of $T$. This way, the dictionary takes space proportional to the number of patterns $d=|\\mathcal{D}|$ rather than their total length, which could be $\\Theta(n\\cdot d)$. An $\\tilde{\\mathcal{O}}(n+d)$-size data structure that answers $CountDistinct(i,j)$ queries $\\mathcal{O}(\\log n)$-approximately in $\\tilde{\\mathcal{O}}(1)$ time was recently proposed in a work that introduced internal dictionary matching [ISAAC 2019]. Here we present an $\\tilde{\\mathcal{O}}(n+d)$-size data structure that answers $CountDistinct(i,j)$ queries $2$-approximately in $\\tilde{\\mathcal{O}}(1)$ time. Using range queries, for any $m$, we give an $\\tilde{\\mathcal{O}}(\\min(nd/m,n^2/m^2)+d)$-size data structure that answers $CountDistinct(i,j)$ queries exactly in $\\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 $\\mathcal{O}(n \\log^2 n)$-size data structure that allows us to count distinct squares in a text fragment $T[i \\mathinner{.\\,.} j]$ in $\\mathcal{O}(\\log n)$ time.","PeriodicalId":236737,"journal":{"name":"Annual Symposium on Combinatorial Pattern Matching","volume":"493 1-2 1","pages":"0"},"PeriodicalIF":0.0000,"publicationDate":"2020-05-12","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"8","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"Annual Symposium on Combinatorial Pattern Matching","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.4230/LIPIcs.CPM.2020.8","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"","JCRName":"","Score":null,"Total":0}
引用次数: 8
Abstract
We consider the problem of preprocessing a text $T$ of length $n$ and a dictionary $\mathcal{D}$ in order to be able to efficiently answer queries $CountDistinct(i,j)$, that is, given $i$ and $j$ return the number of patterns from $\mathcal{D}$ that occur in the fragment $T[i \mathinner{.\,.} j]$. The dictionary is internal in the sense that each pattern in $\mathcal{D}$ is given as a fragment of $T$. This way, the dictionary takes space proportional to the number of patterns $d=|\mathcal{D}|$ rather than their total length, which could be $\Theta(n\cdot d)$. An $\tilde{\mathcal{O}}(n+d)$-size data structure that answers $CountDistinct(i,j)$ queries $\mathcal{O}(\log n)$-approximately in $\tilde{\mathcal{O}}(1)$ time was recently proposed in a work that introduced internal dictionary matching [ISAAC 2019]. Here we present an $\tilde{\mathcal{O}}(n+d)$-size data structure that answers $CountDistinct(i,j)$ queries $2$-approximately in $\tilde{\mathcal{O}}(1)$ time. Using range queries, for any $m$, we give an $\tilde{\mathcal{O}}(\min(nd/m,n^2/m^2)+d)$-size data structure that answers $CountDistinct(i,j)$ queries exactly in $\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 $\mathcal{O}(n \log^2 n)$-size data structure that allows us to count distinct squares in a text fragment $T[i \mathinner{.\,.} j]$ in $\mathcal{O}(\log n)$ time.