07.01.2013 Views

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

Lecture Notes in Computer Science 3472

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

16 Sven Sandberg<br />

Comput<strong>in</strong>g Merg<strong>in</strong>g Sequences. It rema<strong>in</strong>s to show how to compute merg<strong>in</strong>g<br />

sequences. This can be done by construct<strong>in</strong>g a product mach<strong>in</strong>e M ′ =<br />

〈I ′ , S ′ ,δ ′ 〉, with the same <strong>in</strong>put alphabet I ′ = I and no outputs (so we omit<br />

O ′ and λ ′ ). Every state <strong>in</strong> M ′ is a set of one or two states <strong>in</strong> M, i.e., S ′ =<br />

{{s}, {s, t} : s, t ∈ S}. Intuitively, these sets correspond to possible f<strong>in</strong>al states<br />

<strong>in</strong> M after apply<strong>in</strong>g a sequence to the s0, t0 chosen on l<strong>in</strong>e 4 of Algorithm 2.<br />

Thus we def<strong>in</strong>e δ ′ by sett<strong>in</strong>g {s, t} a<br />

−→{s ′ , t ′ } <strong>in</strong> M ′ if and only if s a<br />

−→s ′ and<br />

t a<br />

−→t ′ <strong>in</strong> M, wherewemayhaves = t or s ′ = t ′ .Inotherwords,δ ′ is the restriction<br />

of δ to sets of size one or two. Clearly, δ ′ ({s, t}, x )={s ′ , t ′ } if and only<br />

if δ({s, t}, x )={s ′ , t ′ } (where <strong>in</strong> the first case {s, t} and {s ′ , t ′ } are <strong>in</strong>terpreted<br />

as states of M ′ and <strong>in</strong> the second case as sets of states <strong>in</strong> M). See Figure 1.5<br />

for an example of the product mach<strong>in</strong>e. Thus, to f<strong>in</strong>d a merg<strong>in</strong>g sequence for s<br />

and t we only need to check if it is possible to reach a s<strong>in</strong>gleton set from {s, t}<br />

<strong>in</strong> M ′ . This can be done, e.g., us<strong>in</strong>g breadth-first search [CLRS01].<br />

a, b<br />

s2<br />

a<br />

s1<br />

b<br />

b<br />

a<br />

s3<br />

a<br />

b<br />

s1, s2<br />

b<br />

s2, s3<br />

a<br />

a<br />

a, b<br />

s1, s3<br />

s1 s2 s3<br />

a<br />

b<br />

a<br />

Fig. 1.5. A Mealy mach<strong>in</strong>e M and the correspond<strong>in</strong>g product mach<strong>in</strong>e M ′ . Outputs<br />

are omitted here. In the product mach<strong>in</strong>e, edges <strong>in</strong> the shortest path forest are solid<br />

and other edges are dashed.<br />

Efficient Implementation. The result<strong>in</strong>g algorithm is easily seen to run <strong>in</strong><br />

time O(n 4 + n 3 ·|I |). In each of the O(n) iterations, we compute δ(S, xy) by<br />

apply<strong>in</strong>g y to every element of δ(S, x ). S<strong>in</strong>ce |y| = O(n 2 )and|δ(S, x )| = O(n),<br />

this needs O(n 3 ) time per iteration. The breadth first search needs l<strong>in</strong>ear time<br />

<strong>in</strong> the size of M ′ , i.e., O(n 2 ·|I |). We now show how to save a factor n, us<strong>in</strong>g<br />

several clever tricks due to Eppste<strong>in</strong> [Epp90].<br />

Theorem 1.15 ([Epp90]). Algorithm 2 can be implemented to consume time <strong>in</strong><br />

O(n 3 + n 2 ·|I |) and work<strong>in</strong>g space O(n 2 + n ·|I |) (not count<strong>in</strong>g the space for<br />

the output).<br />

The extra condition “not count<strong>in</strong>g the space for the output” is necessary because<br />

the only known upper bound on the length of synchroniz<strong>in</strong>g sequences is<br />

b<br />

b

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!