Linear search
Quote
“When in doubt, use brute force.” — Ken Thompson
Case | Time complexity | Space complexity |
---|---|---|
Best | \(\color{white} \fcolorbox{limegreen}{forestgreen} {Ω(1)}\) | |
Average | \(\color{black} \fcolorbox{gold}{yellow} {Θ(n)}\) | |
Worst | \(\color{black} \fcolorbox{gold}{yellow} {O(n)}\) | \(\color{white} \fcolorbox{limegreen}{forestgreen} {O(1)}\) |
Linear search or sequential search, iterates through each element until item is found.
Use cases¶
- The list to search is small