Why is Binary Search a divide and conquer algorithm?

后端 未结 16 2308
醉话见心
醉话见心 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条回答
  •  萌比男神i
    2020-12-14 02:41

    The Merge Sort and Quick Sort algorithms use the divide and conquer technique (because there are 2 sub-problems) and Binary Search comes under decrease and conquer (because there is 1 sub-problem).

    Therefore, Binary Search actually uses the decrease and conquer technique and not the divide and conquer technique.

    Source: https://www.geeksforgeeks.org/decrease-and-conquer/

提交回复
热议问题