Computer Science

Big O Linear Search

Describe the time complexity of linear search.

Best Case = O(1); Average/Worst Case = O(n)

Formula Explanation

Linear search checks elements sequentially until a match is found or the collection ends.

Variables Explained

n = Number of elements.

Solved Example

What is the worst-case number of checks for 100 elements?
Up to 100 element checks; the time complexity is O(n).

Exam Tip

The best case occurs when the target is the first element.