Why is Binary Search a divide and conquer algorithm?

后端 未结 16 2316
醉话见心
醉话见心 2020-12-14 02:12

I was asked if a Binary Search is a divide and conquer algorithm at an exam. My answer was yes, because you divided the problem into smaller subproblems, until you reached y

16条回答
  •  暖寄归人
    2020-12-14 02:40

    I think it is not divide and conquer, see first paragraph in http://en.wikipedia.org/wiki/Divide_and_conquer_algorithm

    recursively breaking down a problem into two or more sub-problems which are then combined to give a solution

    In binary search there is still only one problem which does just reducing data by half every step, so no conquer (merging) phase of the results is needed.

提交回复
热议问题