Abstract

The subsequence character count problem has as its input an array S = s1, i­, sn of symbols over alphabet ¦² and a natural number m. Its output is: for every i, i = 1, i­, n - m + 1, the number of different alphabet symbols occurring in the subsequence si, si+1, i­, si+m-1. The subsequence character count problem is a natural problem that has many uses. It can be solved in linear time for fixed finite alphabets and in time O(n log m) for infinite alphabets. In [1] the problem was used to solve the parameterized matching problem.The character count problem can be generalized to two dimensions and becomes the submatrix character count problem. Its input is an n x n matrix T over alphabet ¦² and a natural number m. Its output is: for every i,j, i,j = 1, i­, n - m + 1, the number of different alphabet symbols occurring in the submatrix T[i + k,j + e], k = 0, i­, m - 1;e = 0, i­, m - 1.This problem was motivated by parameterized matching in two dimensions which is a good model for seeking a pattern in an image with a change of color map. The number of different colors in a subarea of an image is considered a signature. There are many image processing tools that use this measure (see e.g. [5]).The straightforward one dimensional solution slides a window along the text adding an element and deleting an element at every step. The problem with two dimensions is that at every move of the window there are m elements added and m deleted.In this paper we present an alternate solution that generalizes to two dimensions. We achieve a O(n2) time solution to the submatrix character count problem over finite fixed alphabet and a O(n2 log m) solution over an infinite alphabet.The submatrix character count problem is a special case of the color range query problem, where one needs to preprocess a two dimensional nxn array T of symbols over alphabet ¦² - the colors. Subsequently we are interested in answers to queries of the type: Given intervals [i1,j1] and [i2,j2], i1,i2,j1,j 2 ¦A {1, i­, n} and i1 iU j1, i2 iU j2 give the number of different alphabet symbols (colors) occurring in the submatrix T[k,e], k = i1, i­,j1, e = i2,i­,j2.Jonardan and Lopez [6] showed that with a O(n2 log2n) preprocessing one can answer queries in time O(log2n). This means that the submatrices character count problem can be solved in time O(n2 log2n) by preprocessing and then querying, for every location, the m x m submatrix starting at that location.We are not aware of a faster direct approach for solving the submatrix character count problem. However, problems with a similar flavor, where the desired calculation is a convolution, are solved in electrical engineering by a method called Separable Convolutions or Separable Filters [4]. A similar notion was used by Bird [3] and Baker [2] to solve the two dimensional pattern matching problem.The contributions of this paper are two-fold. First, We generalize the notion of separable convolutions to separable attributes. We believe it is important to keep this method in mind as an element of the basic algorithmic toolkit. It has proven useful in the past and, we think, will prove useful for solving various two-dimensional problems in the future. Secondly, We use the separable attributes method for providing the fastest algorithm yet for the submatrices character count problem.A full version of this paper can be found at http://www.cs.biu.ac.il/~amir/Postscripts/sep.ps.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.