23.11.2014 Views

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

Data Structures and Algorithms in Java[1].pdf - Fulvio Frisone

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A <strong>Java</strong> implementation of the KMP pattern match<strong>in</strong>g algorithm is shown <strong>in</strong> Code<br />

Fragment 12.6.<br />

Code Fragment 12.6: <strong>Java</strong> implementation of the<br />

KMP pattern match<strong>in</strong>g algorithm. The algorithm is<br />

expressed by two static methods: method KMPmatch<br />

performs the match<strong>in</strong>g <strong>and</strong> calls the auxiliary method<br />

computeFailFunction to compute the failure function,<br />

expressed by an array. Method KMPmatch <strong>in</strong>dicates<br />

the absence of a match by return<strong>in</strong>g the conventional<br />

value −1.<br />

761

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!