Linear Search is basically a sequential search algorithm.
In this algorithm, the key element is searched in the given input array in sequential order.
If the key element is found in the input array, it returns the element.
Linear_Search ( Array X, Value i)
Output:
The best-case complexity is O(1) if the element is found in the first iteration of the loop.
The worst-case time complexity is O(n), if the search element is found at the end of the array, provided the size of the array is n.
Thus, in this article, we have understood and implemented Linear Search Algorithm.
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
not understand why size is has a 10. don’t be 7?
- rafael andrade lamonier