zoukankan      html  css  js  c++  java
  • What's binary search?

    Binary Search: Search a sorted array by repeatedly  dividing the search interval in half. Begin with an interval covering the whole array. If the value of the search key is less than the item in the middle of the interval, narrow the interval to the lower half. Otherwise narrow it to the upper half. Repeatedly check until the value is found or the interval is empty.

    Binary search algorithm

    In computer science, binary search, also known as half-interval search,[1] logarithmic search,[2] or binary chop,[3] is a search algorithm that finds the position of a target value within a sorted array.[4][5] Binary search compares the target value to the middle element of the array; if they are unequal, the half in which the target cannot lie is eliminated and the search continues on the remaining half until it is successful. If the search ends with the remaining half being empty, the target is not in the array.

  • 相关阅读:
    2017普及组D1T3 洛谷P3956 棋盘
    2017提高组D1T1 洛谷P3951 小凯的疑惑
    Title
    Title
    Title
    Title
    Title
    Title
    Title
    Title
  • 原文地址:https://www.cnblogs.com/lightwindy/p/8548819.html
Copyright © 2011-2022 走看看