Exercise 2.2-3

Consider linear search again (see Exercise 2.1-3). How many elements of the input sequence need to be checked on the average, assuming that the element being searched for is equally likely to be any element in the array? How about in the worst case? What are the average-case and worst-case running times of linear search in \(\Theta\)-notation? Justify your answers.

On average, we would be examining \(\frac{n}{2}\) elements before finding our desired value. In the worst-case, we would need to look at all \(n\) elements. In both of these cases, \(n\) is the only significant figure therefore both running times are \(\Theta(n)\).