What is the time complexity of linear search?

Searching Algorithms Questions Medium



24 Short 58 Medium 71 Long Answer Questions Question Index

What is the time complexity of linear search?

The time complexity of linear search is O(n), where n is the number of elements in the list or array being searched. In linear search, each element is checked one by one until a match is found or the end of the list is reached. Therefore, in the worst-case scenario, the algorithm may need to iterate through all n elements, resulting in a time complexity of O(n).