Overview
Shift-Or is the complement-style sibling of Shift-And: it precomputes character masks and updates a bit-vector as the text is scanned, reporting a match when the final state bit clears.
Performs exact string matching with bit masks that track unmatched pattern positions.
Compact metadata for implementation and discovery.
Shift-Or is the complement-style sibling of Shift-And: it precomputes character masks and updates a bit-vector as the text is scanned, reporting a match when the final state bit clears.
Quick facts
Runtime and memory behavior at a glance.
Best
O(n)
Average
O(n + m)
Worst
O(n + m)
Space
O(n + m)
Show using inverted bit masks to update matching states per character on a small exact string matching example.
The algorithm is compact but easy to get backwards because the active states are represented with cleared bits.
What each reference supports for this entry.
String algorithms reference for Shift-Or Algorithm's pattern matching, suffix indexing, alignment, or sequence-processing mechanism.
Open sourceTextbook support for Shift-Or Algorithm's algorithm family, complexity framing, and standard implementation concepts.
Open sourceGood next jumps from the relationship graph, ranked for useful discovery.
Pattern Matching · Core
Both address exact string matching, but they make different modeling or performance tradeoffs.
Compare with thisPattern Matching · Core
Both address longest common prefix array, but they make different modeling or performance tradeoffs.
Compare with thisPattern Matching · Core
Both address exact string matching, but they make different modeling or performance tradeoffs.
Compare with thisPattern Matching · Core
Prefix Function and Shift-Or Algorithm solve related pattern preprocessing problems with different assumptions and tradeoffs.
Compare with thisShift-Or Algorithm and Bit-Parallel Levenshtein solve related exact string matching problems with different assumptions and tradeoffs.
Shift-Or Algorithm and Shift-And Algorithm solve related exact string matching problems with different assumptions and tradeoffs.
Shift-Or Algorithm and BNDM solve related exact string matching problems with different assumptions and tradeoffs.