Data Structures•Easy
Linear Search
Linear Search

Linear Search is the simplest method for finding an element in an array. It involves checking each element of the array sequentially, starting from the first element, until the target element is found or the end of the array is reached.
Complexity Analysis
- Time Complexity:
- Best Case:
O(1)(when the target is at the very first index) - Average Case:
O(N)(when the target is somewhere in the middle or arbitrary position) - Worst Case:
O(N)(when the target is at the last index or not present in the array)
- Best Case:
- Space Complexity:
O(1)(requires no extra memory beyond a few local variables)