Searching Algorithm
Searching Algorithm
Also known as the sequential search, the linear search is the most basic
searching algorithm. With a big-O notation of O(n), the linear search consists of
comparing each element of the data structure with the one you are searching for.
It's up to your implementation whether you return the value you were looking
for or a boolean according to whether or not the value was found. As you can
probably guess, this is a very inefficient process.
The steps to this algorithm are the same as the steps for binary search except for
the first step. Instead of selected a value in the middle of the array as the value,
we will select it using the position formula which you will notice in our
implementation below: