释义 |
DictionarySeebinarybinary search
binary search[′bīn·ə·rē ′sərch] (computer science) A dichotomizing search in which the set of items to be searched is divided at each step into two equal, or nearly equal, parts. Also known as binary chop. binary search (algorithm)A search algorithm which repeatedly divides anordered search space in half according to how the required(key) value compares with the middle element.
The following pseudo-C routine performs a binary searchreturn the index of the element of vector "thing[first..last]"equal to "target":
if (target < thing[first] || target > thing[last])return NOT_FOUND;while (first < last)mid =if (target == thing[last])return last;return NOT_FOUND;binary searchA technique for quickly locating an item in a sequential list. The desired key is compared to the data in the middle of a sequential index or in the middle of a sequential file. The half that contains the data is then compared in the middle, and so on, either until the key is located or a small enough group is isolated to be sequentially searched. See binary. |