186k views
0 votes
The array names (0) names (1) names [9999] is a list of 10,000 name strings. The list is to be searched to determine the location of some name x in the list. Which of the following preconditions is necessary for a binary search?

(A) There are no duplicate names in the list.
(B) The number of names N in the list is large.
(C) The list is in alphabetical order.
(D) Name x is definitely in the list.
(E) Name x occurs near the middle of the list.

User Agscala
by
8.2k points

1 Answer

3 votes

Final answer:

The necessary precondition for a binary search algorithm is that the list is sorted, specifically in this context, in alphabetical order.

Step-by-step explanation:

The precondition necessary for a binary search is (C) The list is in alphabetical order. 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. The presence of duplicates, the largeness of the number, or the position of the target value in the list do not affect the ability to use binary search, as long as the list is sorted. The item being searched for does not even need to be in the list for binary search to be used to determine its potential location in the sorted list.

User Mahdi BM
by
8.3k points