## Invitation to Computer Science 8th Edition

Published by Cengage Learning

# Chapter 3 - Exercises - Page 141: 6

#### Answer

First, we search for Sherman in the list. Since it's the first element of the list, it takes just one comparison to get to it. To find Jane we perform 2 comparisons. To find Ted, which is the third on the list, we need 3 comparisons. It's easy to notice that for each n-th name we need n comparisons. The average of the comparisons is the sum $1+2+3+4+5+6+7$ divided by $7 .$ We can use the formula $\frac{n *(n+1)}{2}$ for the sum. Dividing the sum by $n$ (7 in our case) gives us $\frac{n+1}{2},$ in our case $\frac{7+1}{2}=4$ We have reached the expression that we have used previously $\frac{n+1}{2}$

#### Work Step by Step

--

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.