the boyer-moore algorithm at firstit might seem that it is always necessary to examine every character in in order to locate pattern as substring or to rule out its existence but this is not always the case the boyer-moore pattern-matching algorithmwhich we study in this sectioncan sometimes avoid comparisons between and sizable fraction of the characters in in this sectionwe describe simplified version of the original algorithm by boyer and moore the main idea of the boyer-moore algorithm is to improve the running time of the brute-force algorithm by adding two potentially time-saving heuristics roughly statedthese heuristics are as followslooking-glass heuristicwhen testing possible placement of against tbegin the comparisons from the end of and move backward to the front of character-jump heuristicduring the testing of possible placement of within ta mismatch of text character [ ]= with the corresponding pattern character [kis handled as follows if is not contained anywhere in pthen shift completely past [ (for it cannot match any character in potherwiseshift until an occurrence of character in gets aligned with [iwe will formalize these heuristics shortlybut at an intuitive levelthey work as an integrated team the looking-glass heuristic sets up the other heuristic to allow us to avoid comparisons between and whole groups of characters in in this case at leastwe can get to the destination faster by going backwardsfor if we encounter mismatch during the consideration of at certain location in tthen we are likely to avoid lots of needless comparisons by significantly shifting relative to using the character-jump heuristic the character-jump heuristic pays off big if it can be applied early in the testing of potential placement of against figure demonstrates few simple applications of these heuristics texte patterns figure simple example demonstrating the intuition of the boyer-moore pattern-matching algorithm the original comparison results in mismatch with character of the text because that character is nowhere in the patternthe entire pattern is shifted beyond its location the second comparison is also mismatchbut the mismatched character occurs elsewhere in the pattern the pattern is next shifted so that its last occurrence of is aligned with the corresponding in the text the remainder of the process is not illustrated in this figure