Why is Binary Search a divide and conquer algorithm?

后端 未结 16 2296
醉话见心
醉话见心 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:52

    The book

    Data Structures and Algorithm Analysis in Java, 2nd edtition, Mark Allen Weiss
    

    Says that a D&C algorithm should have two disjoint recursive calls. I.e like QuickSort. Binary Search does not have this, even if it can be implemented recursively, so I guess this is the answer.

提交回复
热议问题