Algorithms - Chapter II jobs

1. Talk about your experience on the dichotomy of thought

A: The main dichotomy is a special partition of the thinking process, the search area is mainly divided into the number of elements in the two portions is substantially the same, the intermediate elements selected for comparison, if the ratio is equal to the end, If large if small, points recursive, so that the issue of the census area becomes half the total number of original elements ...

So that the time complexity of the algorithm is reduced to O (logn)

But the premise is the ability to issue the required two can continue to be divided into two minor problems, but also pay attention to the boundary conditions set and return values ​​must be clear.

 

Report on the programming of junction 2

It will be completed in the classroom three questions, but did not think the third question of the use of dichotomy, so that the time complexity is n-type.

In two of them met on the border issue is the choice of the value of the second question, by way of example later after substitution into sub resolved.

Guess you like

Origin www.cnblogs.com/JeffKing11/p/11635458.html