length and apattern string of length mand want to find whether is substring of the notion of "matchis that there is substring of starting at some index that matches pcharacter by characterso that [ip[ ] [ [ ] [ [ that isp [ thusthe output from pattern matching algorithm could either be some indication that the pattern does not exist in or an integer indicating the starting index in of substring matching this is exactly the computation performed by the indexof method of the java string interface alternativelyone may want to find all the indices where substring of matching begins in this sectionwe present three pattern matching algorithms (with increasing levels of difficultybrute force the brute force algorithmic design pattern is powerful technique for algorithm design when we have something we wish to search for or when we wish to optimize some function in applying this technique in general situation we typically enumerate all possible configurations of the inputs involved and pick the best of all these enumerated configurations in applying this technique to design the brute-force pattern matching algorithmwe derive what is probably the first algorithm that we might think of for solving the pattern matching problem--we simply test all the possible placements of relative to this algorithmshown in code fragment is quite simple algorithm bruteforcematch( , )inputstrings (textwith characters and (patternwith characters outputstarting index of the first substring of matching por an indication that is not substring of for to {for each candidate index in tdo while ( and [ jp[ ]do if then return return "there is no substring of matching code fragment brute-force pattern matching