Linear search is not considered the most efficient search algorithm, especially for lists of large magnitudes. However, linear search is a great choice if you expect to find the target value at the beginning of the list, or if you have a small list.
The best case performance for linear search occurs when the target value exists in the list and is in the first position of the list. In this case, the linear search algorithm will only be required to make one comparison. The time complexity for linear search in its best case is O(1).
You decide to visit a new coffee shop for an espresso. Unfamiliar with their menu, you are unsure if they serve espresso, so you use Linear Search to scan the menu. You are able to efficiently find your desired drink because it was at the top of the menu.
Instructions
How many comparisons were made to find ‘espresso’ on the drink menu?