ArraysLesson 12Free preview
DSA Linear Search
This lesson is part of DSA · All levels
Summary
Linear search searches the list one by one from the beginning until it finds a target or a list of finished ones. This method is simple and can work on data that is not sorted or stored on a sequential structure. Because it has to examine all the elements in the worst case, its complexity is linear, i.e. O(n).
Key points
- Check each element in sequence from the beginning of the list
- No need for data sequencing
- Returns the index or marker -1 when the target is not found
- Complexity in all cases
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.