In string matching algorithm, we check whether a text T contains a pattern P(length of T>P) i.e to check whether P is a substring of T or not. Since we are trying to check a fixed string P, sometimes these algorithms are called exact string matching algorithms.
In brute force method, for each possible in the text T(length n), we check whether the pattern P(length m) matches or not. We loop from start position of the text T and compare each position of the text with each position of the text. If a mismatch is found then we loop from second position and perform comparisons. It continues until the position n-m of the text.
Do refer the code available the end of this section to understand the following theory.
Please open this in your pc or with a compatible app in your mobile.
C++ Implementation for STRING MATCHING USING BRUTE FORCE TECHNIQUEThat's it from this blog post. If you liked it then do share this blog with your friends or people who wanna get into programming world. Thank You!