Counting the maximum memory needed by the algorithm
Item is the last element in the array or is not there at all
The worst case for a linear search algorithm occurs when the item being searched for is either not in the array at all or is the last element in the array. This is because in the worst case, the algorithm will have to iterate through every element in the array before determining that the item is not present or finding the item at the end of the array.
If the item is somewhere in the middle of the array, the linear search algorithm will typically find it faster than if it is at the end of the array or not present at all. This is because the algorithm will be able to eliminate a portion of the array as it searches, rather than having to check every element.
1) The average case occurs in the Linear Search Algorithm when the item to be searched is in somewhere middle of the Array.
2) The best case occurs in the Linear Search Algorithm when the item to be searched is in starting of the Array.
3)The worst case occurs in the Linear Search Algorithm when the item to be searched is in end of the Array.
When Item is somewhere in the middle of the array
1) The average case occurs in the Linear Search Algorithm when the item to be searched is in somewhere middle of the Array.
2) The best case occurs in the Linear Search Algorithm when the item to be searched is in starting of the Array.
3)The worst case occurs in the Linear Search Algorithm when the item to be searched is in end of the Array.