Linear search
A simple searching algorithm that checks each element sequentially until finding the target or reaching the end. Linear search works on unsorted and sorted data, making it universally applicable. Time complexity is O(n) in worst case when target is last or absent. Space complexity is O(1) as no extra space is required.
Formula
Worst-case comparisons = n
Real World
When Spotify searches your offline playlist for a downloaded song, it checks each track one by one — just like linear search — because your playlist isn't necessarily sorted alphabetically.
Exam Focus
State both best case O(1) and worst case O(n); examiners expect you to distinguish between them.
How well did you know this?