# Designing a pattern searching algorithm.

Algorithms are useful for many things. They are important because they allow us to find the best way possible to find a problem. Algorithms are used in all areas of computing. Today I’m going to show you how I’ve designed and planned my algorithm and how I’ve created my flowchart to better help me produce a pseudocode.

PLANNING THE ALGORITHM

The problem: I have two strings ‘text’ and ‘pattern’.
I have to search through the value of ‘text’ and ‘pattern’ to check if the value pattern cam be found within the text.

1. Begin with two string variables: ‘text’ and ‘pattern’
2. Obtain input from user and assign it to the variables ‘text’ and ‘pattern’.
3. Initialize a Boolean variable ‘pattern’ to False, indicating that the pattern has not been found.
4. Iterate through each character in the ‘text’ string.
5. Check if the current substring from the ‘text’ matches the ‘pattern’. If so, set the ‘pattern’ variable to true and exit loop. If not, continue to the next iteration of the loop.
6. After the loop completes, check the value of the ‘pattern’ variable. If ‘pattern’ is true, notify the user that the pattern was found in the text. If ‘pattern’ is false, notify the user that the pattern was not found in the text.
7. End the algorithm.

## Pseudocode

```````Input text and pattern
Enter value for text and pattern variables
Initialize pattern variable to FALSE
If the full text hasn't been searched
Iterate the next character in text
If the pattern is found:
change variable to true
If the pattern is found in the text
TRUE:
notify user pattern found
otherwise:
ERROR`

``````

## Conclusion

Although algorithms and code can be intimidating to many, they are essential to our tech world. Without them the computers and internet would not be as simple to operate as they are today. Software engineers work everyday to create algorithms and codes to help simplify the users life on the computer, apps, and more.