Skip to main content
QUICK REVIEW

[Paper Review] Efficient Pattern Matching on Binary Strings

Simone Faro, Thierry Lecroq|ArXiv.org|Oct 14, 2008
Algorithms and Data CompressionComputer Science10 references12 citations
TL;DR

This paper presents two efficient algorithms—Binary-Skip-Search and Binary-Hash-Matching—for pattern matching on binary strings, designed to process data byte-by-byte without bit-level operations. Both algorithms outperform existing methods, with Binary-Skip-Search being up to 10 times faster than Binary-Boyer-Moore and 100 times faster than Binary-Naive under uniform character distributions, while Binary-Hash-Matching reduces text inspections by over 50% compared to Boyer-Moore in non-uniform cases.

ABSTRACT

The binary string matching problem consists in finding all the occurrences of a pattern in a text where both strings are built on a binary alphabet. This is an interesting problem in computer science, since binary data are omnipresent in telecom and computer network applications. Moreover the problem finds applications also in the field of image processing and in pattern matching on compressed texts. Recently it has been shown that adaptations of classical exact string matching algorithms are not very efficient on binary data. In this paper we present two efficient algorithms for the problem adapted to completely avoid any reference to bits allowing to process pattern and text byte by byte. Experimental results show that the new algorithms outperform existing solutions in most cases.

Motivation & Objective

  • To address the inefficiency of classical string matching algorithms when applied to binary data, where bit-level operations significantly slow performance.
  • To design algorithms that process binary strings at the byte or word level, eliminating costly bit-wise manipulations.
  • To achieve superior practical performance in real-world applications involving binary data, such as network protocols, image processing, and compressed text.
  • To evaluate and compare the new algorithms against existing solutions under various distribution patterns of binary data.
  • To demonstrate that block-based processing can yield substantial speedups without sacrificing correctness or worst-case time complexity.

Proposed method

  • Adaptation of the q-Hash algorithm to binary strings by processing 8-bit blocks (bytes) directly, avoiding individual bit access.
  • Design of a new Binary-Skip-Search algorithm that skips multiple bytes per comparison, leveraging byte-aligned pattern matching.
  • Use of a block-based model where each byte is treated as a single unit, enabling efficient comparison and shift operations.
  • Employment of a lookup table for precomputed shift values in Binary-Skip-Search to minimize character inspections.
  • Integration of a hash function over byte-sized chunks to enable fast filtering of non-matching positions in Binary-Hash-Matching.
  • Implementation of both algorithms to avoid any bit-level operations, focusing solely on byte or word-level processing for efficiency.

Experimental results

Research questions

  • RQ1Can classical string matching algorithms be significantly optimized for binary data by avoiding bit-level operations?
  • RQ2How does byte-level processing compare to bit-level processing in terms of performance for binary string matching?
  • RQ3What is the impact of character distribution (uniform vs. non-uniform) on the performance of binary string matching algorithms?
  • RQ4Can block-based algorithms achieve both high speed and low inspection counts in practical scenarios?
  • RQ5How do the proposed algorithms compare to existing variants like Binary-Boyer-Moore and Binary-Naive in terms of runtime and text inspections?

Key findings

  • The Binary-Skip-Search algorithm is up to 10 times faster than Binary-Boyer-Moore and 100 times faster than Binary-Naive under uniform character distributions.
  • Binary-Skip-Search performs less than 50% of the text character inspections required by Binary-Boyer-Moore, especially for long patterns.
  • The Binary-Hash-Matching algorithm reduces the number of text inspections to less than 50% of those performed by Binary-Boyer-Moore in non-uniform distributions.
  • Binary-Hash-Matching achieves at least a two-fold speedup over Binary-Boyer-Moore in non-uniform cases, with consistent performance gains.
  • Both proposed algorithms outperform existing solutions in all tested scenarios, with Binary-Skip-Search excelling under uniform distributions and Binary-Hash-Matching under non-uniform ones.
  • The experimental results confirm that byte-level processing without bit manipulation yields superior practical performance across all test conditions.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.