Help with Z algorithm without sentinel

Revision en1, by binary_eagle, 2015-12-26 00:23:42

Hi guys,

I am familiar with the Z algorithm for exact string matching.

However, is there a way to do this without using the sentinel

which is commonly #?

An idea i have is if m is the length of the pattern and n the length of the text, then we can do this

let S = P+T compute Z table

since the pattern is of length n, start iterating from i = m to i = n+m-1 if Z[i] >= m then we have a match at i. Is this correct?

Tags string matching, z algorithm, kmp, string algorithms

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English binary_eagle 2015-12-26 00:23:42 476 Initial revision (published)