StringSearching - String Search Boyer-Moore Algorithm...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
String Search Boyer-Moore Algorithm Pattern matching algorithm useful for non-repetitive sequences from large alphabets. Relies on a last function to determine by how much to shift. Letters are checked right-to-left. Demo: http://www.prism.gatech.edu/~jgirata3/boyermoore Pattern: RACECAR The last function is calculated by associating each letter with a number. The letters in the string receive the value of the right-most position of that letter. Letters not in the string receive a value of -1. So: R A C E C A R 0 1 2 3 4 5 6 Gives a last function: R: 6 A: 5 C: 4 E: 3 Everything else: -1 When searching through text, you start from right to left, and continue until a mismatch occurs. If a mismatch occurs, you move the string to the right by length(pattern) - last[‘letter that caused mismatch’] - 1 spaces. If you reach the end of the string without a mismatch, you return the found position of the string in the text. An example: Text: CACECARR ACDFGHIJKL RACECAR Pattern: RACECAR CACECARR ACDFGHIJKL RACECAR RACECAR
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Mismatch occurs between ‘C’ and ‘R’ so length(‘RACECAR’) = 7 last[‘C’] = 4 shift amount: 7 - 4 - 1 = 2 CACECARR ACDFGHIJKL RACECAR RACECAR Shift: 7 -(-1) - 1 = 7 CACECARR ACDFGHIJKL RACECAR RACECAR Shift: 7 -(-1) -1 = 7 CACECARR ACDFGHIJKL RACECAR
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/23/2011 for the course COMPUTER S 1332 taught by Professor Sweat,monica during the Fall '10 term at Georgia Tech.

Page1 / 5

StringSearching - String Search Boyer-Moore Algorithm...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online