The Naive string searching algorithm is also called the simple string searching algorithm. It employs a brute force technique to identify the presence of a pattern in the given text. Even though the working of the algorithm can be understood easily, it is not an efficient algorithm. The time complexity of the algorithm to check for a sub string is O(mn) where m is the length of the text and n is the length of the pattern (sub string) to be searched. But no preprocessing is required for this algorithm.
Click here to download the C Program implementing The Naive String Searching Algorithm.
Click here to download the C++ Program implementing The Naive String Searching Algorithm.