Python DSALesson 103Free preview
Linear Search
This lesson is part of Python · All levels
Summary
This lesson describes linear search, the simplest search technique that examines every single element of data one by one from start to finish. Linear search doesn't require data in a sequential state, so it's easy to implement for small data sets. You'll learn how to write a search function and return the index of findings.
Key points
- Linear search tracks the sequential data and stops when the target is found or the data runs out.
- The best time complexity and worst time complexity.
- The function usually returns the element index if it is found and -1 if it is not.
- It's suitable for small, unsequenced data, or data that's only accessible once.
- For big data that's always sorted, binary search is much more efficient.
Full lesson
Code examples and quizzes
Full lessons, code examples, and quizzes are available to subscribers. 5 questions.