Seeking wisdom: I have a set of number sequences, given a length parameter n, and minimum occurance parameter m, I'd like to find common continuous subsequences of length n that occur at least m times. Here's an example:
@a = ( [2,5,10,5,12,6,21,5,10,12,23],
[5,6,11,10,5,10,6,21,5,1,9],
[6,5,10,15,21]
);
$m = 2;
$n = 2;
I'd like the result to be the set containing the following sequences (hopefully I haven't missed any):
(5,10) #which occured twice in 1st, once in 2nd and 3rd
(10,5) # which occured once in 1st and 2nd
(6,21,5) # which occured once in 1st and 2nd
performance is a concern since both the length and the number of sequences can be pretty big, say 1000. Thanks.
Update: I meant "at least length n". The subsequence does need to be in different sequences, but I'd like to have
a total count including multiple occurances within the same sequence.
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.