Invitation to Computer Science 8th Edition

Published by Cengage Learning
ISBN 10: 1337561916
ISBN 13: 978-1-33756-191-4

Chapter 3 - Exercises - Page 146: 32

Answer

Average: $2.43$ Worst case: $3$

Work Step by Step

For finding $1$ in the list: $3$ comparisons For finding $2$ in the list: $2$ comparisons For finding $3$ in the list: $3$ comparisons For finding $4$ in the list: $1$ comparisons For finding $5$ in the list: $3$ comparisons For finding $6$ in the list: $2$ comparisons For finding $7$ in the list: $3$ comparisons Average : $\frac{3+2+3+1+3+2+3}{7}=\frac{17}{7}\approx 2.43$ The average, $2.43$, is slightly lower than the worst case which is $3$.
Update this answer!

You can help us out by revising, improving and updating this answer.

Update this answer

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.