Computing Atlas

How Computing Was Built
Sign In
Text size
100%
Theme
Algorithm

Raita algorithm

String Algorithm

The Raita algorithm is a string searching algorithm published by Timo Raita in 1991 that improves on the Boyer-Moore-Horspool algorithm. Like its parent it preprocesses the pattern to build a bad-character shift table, but it changes the order in which each window of the text is compared with the pattern. It first compares the last character of the pattern with the rightmost character of the window, then the first character with the leftmost, then the middle character with the middle one, and only if all three agree does it compare the remaining characters from the second to the last but one. A mismatch at any stage triggers the bad-character shift computed during preprocessing. Preprocessing takes O(m) time for a pattern of length m, and the search stage takes O(mn) time for a text of length n. The source notes that a similar pre-check appears in modern implementations of std::string::find in the libc++ and libstdc++ libraries.

Facts
Time Complexity
Time Complexity (category)
Polynomial Time -- O(n^k) 1
Connections

Credited To

Timo Raita, Pioneers
Source Raita algorithm (Wikipedia)

In Field

Source Raita algorithm (Wikipedia)

Invented

Timo Raita, Pioneers
Source Raita algorithm (Wikipedia)
Sources
1. Raita algorithm (Wikipedia)
  • Complexity section
    Searching stage takes O(mn) time complexity
  • In Group: String Searching Algorithms, Lead paragraph
    the Raita algorithm is a string searching algorithm which improves the performance of Boyer
  • In Field: Algorithms and Complexity Theory, Lead paragraph [in-field]
    the Raita algorithm is a string searching algorithm
  • Credited To: Timo Raita, Lead paragraph
    This algorithm was published by Timo Raita in 1991
  • Invented: Timo Raita, Lead paragraph
    This algorithm was published by Timo Raita in 1991
View the Source
Comments (0)
No comments yet. Be the first to share a thought.
Reader Challenges (0)
No disputes yet. Spotted an error or a better source? Open the first one.