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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.