Abstract
We consider dynamic and online variants of 2D pattern matching between an \(m \times m\) pattern and an \(n \times n\) text. All the algorithms we give are randomised and give correct outputs with at least constant probability.
-
For dynamic 2D exact matching where updates change individual symbols in the text, we show updates can be performed in \( \mathcal {O}(\log ^2 n)\) time and queries in \(\mathcal {O}(\log ^2 m)\) time.
-
We then consider a model where an update is a new 2D pattern and a query is a location in the text. For this setting we show that Hamming distance queries can be answered in \(\mathcal {O}(\log m + H)\) time, where H is the relevant Hamming distance.
-
Extending this work to allow approximation, we give an efficient algorithm which returns a \((1+\varepsilon )\) approximation of the Hamming distance at a given location in \(\mathcal {O}(\varepsilon ^{-2} \log ^2 m \log {\log n})\) time.
Finally, we consider a different setting inspired by previous work on locality sensitive hashing (LSH). Given a threshold k and after building the 2D text index and receiving a 2D query pattern, we must output a location where the Hamming distance is at most \((1+\varepsilon )k\) as long as there exists a location where the Hamming distance is at most k.
-
For our LSH inspired 2D indexing problem, the text can be preprocessed in \(\mathcal {O}(n^{2(4/3+1/(1+\varepsilon ))} \log ^3 n)\) time into a data structure of size \(\mathcal {O}(n^{2(1+1/(1+\varepsilon ))})\) with query time \(\mathcal {O}(n^{2(1/(1+\varepsilon ))} m^2)\).
Keywords
These keywords were added by machine and not by the authors. This process is experimental and the keywords may be updated as the learning algorithm improves.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsReferences
Alon, N., Matias, Y., Szegedy, M.: The space complexity of approximating the frequency moments. In: STOC 1996, pp. 20–29. ACM (1996)
Amir, A., Benson, G.: Efficient two-dimensional compressed matching. In: Data Compression Conference, DCC 1992, pp. 279–288. IEEE (1992)
Amir, A., Benson, G.: Two-dimensional periodicity in rectangular arrays. SIAM J. Comp. 27(1), 90–106 (1998)
Amir, A., Benson, G., Farach, M.: Optimal two-dimensional compressed matching. J. Algorithms 24(2), 354–379 (1997)
Amir, A., Butman, A., Crochemore, M., Landau, G.M., Schaps, M.: Two-dimensional pattern matching with rotations. Theor. Comput. Sci. 314(1), 173–187 (2004)
Amir, A., Farach, M.: Efficient 2-dimensional approximate matching of non-rectangular figures. In: SODA, pp. 212–223 (1991)
Amir, A., Farach, M.: Efficient 2-dimensional approximate matching of half-rectangular figures. Inf. Comput. 118(1), 1–11 (1995)
Amir, A., Landau, G.M., Lewenstein, M., Sokol, D.: Dynamic text and static pattern matching. ACM Trans. Algorithms (TALG), 3(2) (2007)
Amir, A., Landau, G.M., Sokol, D.: Inplace run-length 2D compressed search. Theor. Comput. Sci. 290(3), 1361–1383 (2003)
Andoni, A., Indyk, P.: Efficient algorithms for substring near neighbor problem. In: SODA 2006, pp. 1203–1212 (2006)
Baker, T.P.: A technique for extending rapid exact-match string matching to arrays of more than one dimension. SIAM J. Comp. 7(4), 533–541 (1978)
Bird, R.S.: Two dimensional pattern matching. IPL 6(5), 168–170 (1977)
Cole, R., Hariharan, R.: Dynamic LCA queries on trees. SIAM J. Comput. 34(4), 894–923 (2005)
Fredriksson, K., Navarro, G., Ukkonen, E.: Optimal exact and fast approximate two dimensional pattern matching allowing rotations. In: Apostolico, A., Takeda, M. (eds.) CPM 2002. LNCS, vol. 2373, pp. 235–248. Springer, Heidelberg (2002)
Galil, Z., Park, K.: Truly alphabet-independent two-dimensional pattern matching. In: FOCS 1992, pp. 247–256 (1992)
Giancarlo, R.: A generalization of the suffix tree to square matrices, with applications. SIAM J. Comp. 24(3), 520–562 (1995)
Gusfield, D.: Algorithms on Strings, Trees and Sequences. Computer Science and Computational Biology. Cambridge University Press, Cambridge (1997)
Karp, R.M., Rabin, M.O.: Efficient randomized pattern-matching algorithms. IBM J. Res. Dev. 31(2), 249–260 (1987)
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2016 Springer International Publishing AG
About this paper
Cite this paper
Clifford, R., Fontaine, A., Starikovskaya, T., Vildhøj, H.W. (2016). Dynamic and Approximate Pattern Matching in 2D. In: Inenaga, S., Sadakane, K., Sakai, T. (eds) String Processing and Information Retrieval. SPIRE 2016. Lecture Notes in Computer Science(), vol 9954. Springer, Cham. https://doi.org/10.1007/978-3-319-46049-9_13
Download citation
DOI: https://doi.org/10.1007/978-3-319-46049-9_13
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-319-46048-2
Online ISBN: 978-3-319-46049-9
eBook Packages: Computer ScienceComputer Science (R0)