Skip to main content
QUICK REVIEW

[Paper Review] Dictionary matching in a stream

Raphaël Clifford, Allyx Fontaine|arXiv (Cornell University)|Apr 23, 2015
Algorithms and Data CompressionComputer Science17 references6 citations
TL;DR

This paper presents a randomized streaming algorithm for dictionary matching that achieves O(log log(k+m)) time per character and O(k log m) space, where k is the number of patterns and m is the maximum pattern length. By partitioning patterns into short, periodic, and non-periodic classes and using fingerprinting with progressive matching and colored ancestor queries, the algorithm efficiently detects pattern occurrences with low error probability.

ABSTRACT

We consider the problem of dictionary matching in a stream. Given a set of strings, known as a dictionary, and a stream of characters arriving one at a time, the task is to report each time some string in our dictionary occurs in the stream. We present a randomised algorithm which takes O(log log(k + m)) time per arriving character and uses O(k log m) words of space, where k is the number of strings in the dictionary and m is the length of the longest string in the dictionary.

Motivation & Objective

  • To design a streaming algorithm for dictionary matching that operates with minimal space and low per-character time cost.
  • To handle dictionaries with patterns of varying lengths efficiently, avoiding the O(k) time complexity of independent pattern matching.
  • To reduce space usage to O(k log m) words while maintaining sublinear time per arrival, approaching theoretical space lower bounds.
  • To minimize false positives and false negatives in pattern detection under a strict streaming model with no full storage of input or dictionary.

Proposed method

  • The algorithm partitions dictionary patterns into three classes: short patterns, long patterns with short periods, and long patterns with long periods.
  • For each pattern class, it uses a combination of fingerprinting and progressive matching over power-of-two length prefixes to detect potential matches efficiently.
  • It maintains progressions of candidate matches using a rolling fingerprint data structure that allows O(1) time updates and comparisons.
  • Colored ancestor queries in a compacted trie of reversed pattern suffixes are used to verify full pattern matches and eliminate detection delay.
  • A circular buffer of fingerprints enables constant-time verification of candidate pattern extensions after a bounded delay of k log m characters.
  • The method leverages randomization to achieve a small error probability of O(1/n), where n is the stream length, while staying within optimal space bounds.

Experimental results

Research questions

  • RQ1Can dictionary matching in a stream be performed in sublinear time per character while using near-optimal space?
  • RQ2How can patterns of varying lengths be matched efficiently in a streaming setting without storing the entire dictionary?
  • RQ3What techniques can minimize both time and space complexity in a streaming dictionary matching algorithm with low error probability?
  • RQ4Is it possible to detect full pattern matches with only a bounded delay, even when matching prefixes are found earlier?
  • RQ5Can the space usage be kept within O(k log m) words while achieving O(log log(k+m)) time per character?

Key findings

  • The algorithm achieves O(log log(k+m)) time per character, significantly improving upon the O(k) time of naively running independent pattern matchers.
  • The space complexity is O(k log m) words, which is within a logarithmic factor of the theoretical lower bound of Ω(k log n) bits.
  • The algorithm reports pattern matches with a false positive and false negative probability of O(1/n), where n is the stream length.
  • The detection delay is bounded at k log m characters, and this delay is eliminated using colored ancestor queries in a compacted trie.
  • The method supports efficient verification of full pattern matches by combining fingerprinting with a colored trie structure built on reversed pattern suffixes.
  • The approach enables scalable dictionary matching in streaming environments where full storage of the dictionary or input stream is not feasible.

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.