Ask Question
11 October, 06:14

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

+3
Answers (1)
  1. 11 October, 07:14
    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?
Find 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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers