Search+Practice+Problems

Sequential Search:

Use the following array for questions 1-4.

1. How many comparisons will it take when searching for 9? 2. How many comparisons will it take when searching for 8? 3. How many comparisons will it take when searching for 15? 4. How many comparisons will it take when searching for -3?
 * -3 || 4 || 9 || 1 || 15 || -5 || 6 || 2 || 8 || 7 ||

Binary Search:

Use the following array for questions 5-8. 5. How many comparisons will it take when searching for -1? 6. How many comparisons will it take when searching for 7? 7. How many comparisons will it take when searching for 32? 8. How many comparisons will it take when searching for 14?
 * -1 || 3 || 4 || 7 || 10 || 13 || 14 || 18 || 21 || 32 ||

Answers: 1. 3 2. 9 3. 5 4. 1 5. 3 6. 4 7. 4 8. 4