Simple Search🦌
simple search is a search algorithm used to look for an element in an array or a list.
Time Complexity
The time complexity of a simple search is O(n) i.e. Linear time
Explanation
In order to look for an x element in the simple search we have to check every element in the list, e.g. if there are 10 elements in the list we have to check each element and see if it matches the element which we are looking for.
And in the worst case, that element can be at the end of the list, so for n elements (where n is the number of elements in a list), we have to do n operation on a list. So that’s what the O(n) stands for.