Linear Search/ Sequential Search
Last updated
Last updated
In computer science, linear search, also known as sequential search, is a method for locating a specific value in a list that involves verifying each of the list's members one by one until the desired one is discovered.
The simplest search algorithm is linear search. It's a type of brute-force search with a twist. Its worst-case cost is proportional to the list's amount of items.
Time Complexity: O(n)
Space Complexity: O(1)
Comparing the value of ith index with element to be search one by one until we get searched element or end of the array.
Search for 1 in the given array