Linear search or sequential search is a method for finding a target value within a list. It sequentially checks each element of the list for the target value until a match is found or until all the elements have been searched.
Codes in over 20+ languages: see
Ask anything to our massive community.
Explanation:
How it works ?
Linear search goes through each element of the given array until either the element to be searched is found or we have reached the end of the array.
Time Complexity | Notation |
---|---|
Worst-case performance | O(n) |
Best-case performance | O(1) |
Average performance | O(n) |