15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

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

Searching Phonetically 433<br />

If you had the strings Harry stored in a text file, the Soundex algorithm converts<br />

that string into the H600 code. Now if you searched <strong>for</strong> the string hairy<br />

with the Soundex algorithm, the computer converts hairy into the Soundex<br />

code H600 and then finds the same H600 code stored at the string Harry,<br />

thus finding a matching string phonetically.<br />

Phonetic algorithms are used most often in spell checkers. The algorithm<br />

calculates a code <strong>for</strong> each misspelled word and then matches that code to<br />

correctly spelled words that have the same phonetic code.<br />

String searching algorithms must examine every character, so the only way to<br />

speed up an algorithm is to simplify how it examines a string of text. Paradoxically,<br />

string searching algorithms often run faster by organizing text in a specific<br />

way and then searching that method of organization rather than the actual<br />

text itself, which is how the Shift Or and Soundex algorithms work. As a general<br />

rule, the faster the string searching algorithm, the harder and more complicated<br />

it is to implement.<br />

Book IV<br />

Chapter 3<br />

String Searching

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

Saved successfully!

Ooh no, something went wrong!