Congratulations! You have learned how linear search works and how to use it to search for values in lists.
Let’s review what we learned:
Linear search is a search algorithm that sequentially checks whether a given value is an element of a specified list by scanning the elements of a list one-by-one until it finds the target value.
The time complexity for linear search is O(N), but its performance is dependent on its input:
Linear search is a good choice for a search algorithm when:
You expect the target value to be positioned near the beginning of the list.
A search needs to be performed on an unsorted list because linear search traverses the entire list from beginning to end, regardless of its order.