COMPUTER SCIENCE AND ENGINEERING
ALGORITHMS
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
5
|
|
8
|
|
100
|
|
200
|
Detailed explanation-1: -For a list with 200 elements, the list will be cut in half a maximum of 7 times (with a total of 8 elements examined).
Detailed explanation-2: -The number of comparisons necessary to get to this point is i where n2i=1. Solving for i gives us i=logn. The maximum number of comparisons is logarithmic with respect to the number of items in the list. Therefore, the binary search is O(logn).
Detailed explanation-3: -Answer and Explanation: For a sorted list of 1024 elements, a binary search takes at most 11 comparisons.
Detailed explanation-4: -To perform a binary search, we need to examine the list element at the given position. In this case, the given position is 8, so the first step is to examine the list element at position 8. Since the list contains 200 elements, we will need to examine at least 18 list elements in order to find the desired value.
Detailed explanation-5: -Here, we have to apply the binary search on 32 elements. So, it will take log232 = 5 comparisons to search for the element.