Ask Question
22 February, 07:57

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 110 is in list. Exactly how many key comparisons are executed by binary search?

A) 3

B) 5

C) 8

D) 12

+1
Answers (1)
  1. 22 February, 09:22
    0
    To search 110 is in list we key comparisons binary search will make are option

    (A) 3

    Explanation:

    First the start = 0 and end = 8 and midindex=4.

    So 110 will be compared to element at index 4 that is 45 since 110 is greater than 45 so start will be updated as start=midindex + 1.

    start=5, end = 8 and midindex=6.

    Element at index 6 is 100 so 110 will be compared to 100 since it is greater so again start will be updated midindex+1.

    start=7, end=8 midindex=7

    element at index 7 is 120 so 110 will be compared to 120 since it is smaller than 120 end will be updated as midindex - 1.

    start=7, end=6

    Now we have start > end. So the loop will finish execution.

    Comparison made are 3.
Know the Answer?
Not Sure About the Answer?
Get an answer to your question ✅ “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 ...” in 📙 Computers & Technology if there is no answer or all answers are wrong, use a search bar and try to find the answer among similar questions.
Search for Other Answers