Consider a sequence, e.g.
W7,W8,W1,W9
Any item has
preceding items as well as
following items.
For instance
W8
has
- preceding items
{W7}
- following items
{W1,W9}
Please note either
preceding items or
following items could be the empty set.
Now you can compare two sequences (say sequence
A
and
B
):
for every item of the sequence A
you may have two cases:
- You don't find the same item in sequence
B
- You find the same item in sequence
B
In case 1 there is no mismatch, and you can go on with next item of sequence
A
.
In case 2 you have to make sure that any item in the
preceding items of sequence
A
cannot be found in the
following items of sequence
B
(and viceversa: any item in the
following items of sequence
A
cannot be found in the
preceding items of sequence
B
). If this is not the case then ther is a mismatch and the two sequences are
incompatible.
If two sequences are
compatible then you can merge them in order to obtain a merged sequence that preserves items order. The merged sequence could in turn be compared with another input sequence, and so on.
I think it isn't a smart algorithm, however it could work.