Pattern Matching Algorithms

These are meant to supplement your class notes, but do not substitute for class lectures. Try these algorithms on examples and make sure that you understand how they work. The first algorithm (see Figure 1) describes keyword search without the use of failure nodes, and is therefore slower than the second. The second algorithm (see Figure 2) uses failure function F to ensure a linear running time. These algorithms assume that no pattern is a proper substring of the other. That case needs some special handling but the basic ideas remain the same.