26
Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4 5 6 L i 1 1 1 1 1 1 4 1. Versuch a b a a b c a b b a b a b b c a b a b a

Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 2: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

a

b

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 3: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 4: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 5: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 6: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

a

bbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 7: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

bacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 8: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abb

acba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 9: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abba

cba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 10: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbac

ba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 11: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacb

a

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 12: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 13: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

1. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

2. Versuch

a b a a b c a b b a b a b b c a b a b a

abbacba

Vorkommen gefunden. Verschiebung: 7− L0 = 6.

Page 14: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 15: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

a

b

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 16: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 17: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 18: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 19: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 20: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

3. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

Verschiebung: 7− L6 = 3.

4. Versuch

a b a a b c a b b a b a b b c a b a b a

a

Verschiebung: 7− Rb = 1.

Page 21: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

5. Versuch

a b a a b c a b b a b a b b c a b a b a

abb

Verschiebung: 7− L5 = 6.Schluss.

Page 22: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

5. Versuch

a b a a b c a b b a b a b b c a b a b a

a

bb

Verschiebung: 7− L5 = 6.Schluss.

Page 23: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

5. Versuch

a b a a b c a b b a b a b b c a b a b a

ab

b

Verschiebung: 7− L5 = 6.Schluss.

Page 24: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

5. Versuch

a b a a b c a b b a b a b b c a b a b a

abb

Verschiebung: 7− L5 = 6.Schluss.

Page 25: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

5. Versuch

a b a a b c a b b a b a b b c a b a b a

abb

Verschiebung: 7− L5 = 6.

Schluss.

Page 26: Boyer-Moore-Algorithmus: Beispieltheo.cs.ovgu.de/lehre06w/textalg/beispiele/beispiel-boyermoore.pdf · Boyer-Moore-Algorithmus: Beispiel P = abcabba x a b c R x 7 6 3 i 0 1 2 3 4

Boyer-Moore-Algorithmus: Beispiel

P = abcabbax a b cRx 7 6 3

i 0 1 2 3 4 5 6Li 1 1 1 1 1 1 4

5. Versuch

a b a a b c a b b a b a b b c a b a b a

abb

Verschiebung: 7− L5 = 6.Schluss.