Linear search is a simple search algorithm that works by iterating through
each element in an array until it finds a match.
Linear Search Algorithm
1. Start at the first element of the array.
2. Compare the target value to the current element.
3. If the target value matches the current element, return the index of the
current element.
4. If the target value does not match the current element, move to the
next element in the array.
5. Repeat steps 2-4 until the target value is found or the end of the array
is reached.
6. If the target value is not found, return a value indicating that the
element was not found (e.g. -1).
Example Code
```
int linearSearch(int[] array, int target) {
for (int i = 0; i < array.length; i++) {
if (array[i] == target) {
return i; // return the index of the target value
return -1; // return -1 if the target value is not found
```