36.9k views
0 votes
Consider the following list.

list = {5, 11, 25, 28, 45, 78, 100, 120, 125};

Suppose that binary search as discussed in the book is used to determine whether 28 is in list. What are the values of first and last when the while loop in the body of the binarySearch method terminates?

A. first = 3, last = 3
B. first = 0, last = 3
C. first = 2, last = 4
D. None of these

Consider the following list.

list = {20, 10, 17, 2, 18, 35, 30, 90, 48, 47};

Suppose that sequential search as discussed in the book is used to determine whether 2 is in list. Exactly how many key comparisons are executed by the sequential search algorithm?

A. 3
B. 4
C. 5
D. 8

1 Answer

5 votes

Answer:

The answers are Letter B, first=0, last =3. And Letter B. 4 keys comparisons are executed by the sequential search algorithm.

Step-by-step explanation:

The answer for the first question is letter B:

First= 0, last = 3

THE ANSWER FOR QUESTION 2:

Letter B. 4 keys comparisons are executed by the sequential search algorithm.

User DEHAAS
by
5.3k points