MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A BINARY SEARCH looks for a certain name in a list of sixteen names. What is the most possible number of places it will have to check?
A
1
B
2
C
4
D
8
E
16
Explanation: 

Detailed explanation-1: -The maximum number of comparisons is logarithmic with respect to the number of items in the list. Therefore, the binary search is O(log n) .

Detailed explanation-2: -Binary search is an efficient algorithm for finding an item from a sorted list of items. It works by repeatedly dividing in half the portion of the list that could contain the item, until you’ve narrowed down the possible locations to just one. We used binary search in the guessing game in the introductory tutorial.

Detailed explanation-3: -So with an array of length 8, binary search needs at most four guesses.

There is 1 question to complete.