There are two worst cases for linear search.

Case 1: when the target value at the end of the list.

Case 2: when the target value does not exist in the list.

In both cases, the linear search algorithm is required to scan the entire list of N elements and, therefore, makes N comparisons.

For this reason, the time complexity for linear search in its worst case is O(N).

Vinyl enthusiasts patiently search through crates of vinyl records in search of their favorite musicians. If you used linear search to find the vinyl record, the worse case would be if it is the last record in the crates of records or if it is not in the crates at all. Both cases would require you to search through the entire crate.


In one of the worst cases, the target value is found. Is this case more efficient than the second case because it was able to find the target value in the list? Leave your thoughts on this post in the forum and then click ‘Next’ to move onto the next exercise.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?