Unit SS, Part B: String Matching, Shift-Or


Preprocessing:


Searching:

  • For pattern "ababc" get T[a] = 11010 because "a" is in position 1 and 3 in the pattern.
  • Example of searching for "ababc" in text "abdabadabc"
    text:    a     b     d     a     b     a     b     a     b     c
    T[x]:  11010 10101 11111 11010 10101 11010 10101 11010 10101 01111
    state: 11110 11101 11111 11110 11101 11010 10101 11010 10101 01111
    

    Ex. state "10101 means there are 2 partial matches, of lengths 2,4 (starting at the right)


    Advantages: