Presentation is loading. Please wait.

Presentation is loading. Please wait.

Raita Algorithm T. RAITA Advisor: Prof. R. C. T. Lee

Similar presentations


Presentation on theme: "Raita Algorithm T. RAITA Advisor: Prof. R. C. T. Lee"— Presentation transcript:

1 Raita Algorithm T. RAITA Advisor: Prof. R. C. T. Lee
Tuning the Boyer-Moore-Horspool string searching algorithm, Software - Practice & Experience, 22(10): T. RAITA Advisor: Prof. R. C. T. Lee Speaker: H. M. Chen

2 String Matching Problem
Given a pattern string P of length m and a text string T of length n, we would like to know whether there exists an occurrence of P in T. Text Pattern

3 Basic idea For each position of the search window, we compare its last character(ß) with the last character of the pattern. If they match, we compare the first character of the pattern with that of the window. If they match , we compare the middle character of the pattern with that of the window. Then, we search the pattern from second character to the end until we either find the pattern or fail on a text character. Forward search Text ß 2 3 1 Pattern

4 Basic idea Then, whether there was a match or not, we shift the window according to the next occurrence of the letter ß in the pattern. Text ß Safe shift ß no ß α in this part

5 If a mismatch or a complete match occurs, the Raita algorithm uses the Horspool Algorithm.

6 Preprocessing phase T : P : raBc table
P = p0p1…pm-2pm-1. The value of pm-2 is set to 1, the value of p0 is m-1. The value is increase towards to left from pm-2 to p0. We choose the smallest value of each alphabet. The value of other alphabet(*) is set to m. Example : T : P : G C A T G C A a A C G * raBc[a]

7 Example(1/4) First attempt Secnod attempt A C G * 1 6 2 8 G C A T
First attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T mismatch G C A Secnod attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T 2 mismatch 1 G C A

8 Example(2/4) Third attempt Fourth attempt A C G * 1 6 2 8 G C A T 2
Third attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T 2 mismatch 1 G C A Fourth attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T 2 4 5 6 3 7 8 1 G C A

9 Example(3/4) Fifth attempt Sixth attempt A C G * 1 6 2 8 G C A T
Fifth attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T mismatch G C A Sixth attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T mismatch G C A

10 Example(4/4) Seventh attempt A C G * 1 6 2 8
Seventh attempt 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 G C A T 2 mismatch 1 G C A The Raita algorithm performs 18 character comparisons on the example.

11 Time complexity preprocessing phase in O(m+σ) time and O(σ) space complexity. searching phase in O(mn) time complexity. (σ is the number of storing characters)

12 References RAITA T., 1992, Tuning the Boyer-Moore-Horspool string searching algorithm, Software - Practice & Experience, 22(10): SMITH, P.D., 1994, On tuning the Boyer-Moore-Horspool string searching algorithms, Software - Practice & Experience, 24(4):

13 THANK YOU


Download ppt "Raita Algorithm T. RAITA Advisor: Prof. R. C. T. Lee"

Similar presentations


Ads by Google