Linear Search
Linear search checks items one at a time from the start until it finds the target or runs out. It works on any list, sorted or not, and is easy to get right.
In the worst case the target is last or missing, so it looks at all n items: O(n). It is the right tool for short or unsorted lists.
Examplepython
Quick check
What is the worst case of linear search on n items?
Your turn: write the code
Write find_last(items, target) that returns the index of the LAST occurrence of target, or -1. Print find_last for 3 in the list.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.