减治法——二分查找算法(Decrease and Conquer by a Factor - Binary Search Algorithm)
减治法简介(Introduction)
Decease-and-Conquer is a famous algorithmic design technique. basically, in the approach the size of problem will be reduced by a constant or a factor in each interaction of the algorithm.
Decrease-and-Conquer-by-a-Constatnt: for example, to sort an array of length n. We firstly sort n-1 elements, and then place the last element in its right position. In second iteration, it is sorting n-2 elements, and so on. Problem: n -> n-1 -> n-2 -> … -> 2 -> 1.
Decrease-and-Conquer-by-a-factor: for example, to search a key in an sorted array. We firstly check whether the middle element is the key, if it is, we are done; If the key is greater, go to right portion. Otherwise go to left portion. In this case, the size of problem is reduced by half in each iteration