Half thirds summary

One, two points

  Bipartite basic use is for a binary search ordered sequence of elements, since half of the time complexity is only O (log n), is also possible answers may be used to enumerate the determination, that is half the answer. Examination of the exam most is half the answer (after all, a binary search function has written a STL ...).

  Dichotomous answer questions Summary:

    Dichotomy can answer questions do generally monotonic, that is, within certain limits, this limit bad answers and questions are intended to meet, but not optimal, but the strongest answer than this limit can not meet the meaning of the questions. We will by means of dichotomy seek out this limit. E.g. minimization problem maximum (or minimum maximization problem), and a portion of the optimization problem.

    The advantage that the binary answer to solve the optimal value feasibility determination into question, the time complexity is O (log n * determined complexity). The judgment also often used greedy, and even have to put a half.

    Half pay attention to the domain of integer or real numbers will affect the half cycle of judgment conditions, and occasionally there are accuracy problems - of course, in particular sufficient time when the more precise the better friends.

Second, one-third

  For a side extremes are strictly monotone unimodal function, we often use to seek third of its extreme value. Principle: a period of three aliquots comprising two extrema points will be superior in conjunction with the extreme point, another side of the same trisection point. Order of about three dividing points corresponding to end like attention when maintenance interval.

  Third core code (in this domain as an example of a real number)

. 1  the while (rl is an> = 0.000001 )
 2          {
 . 3              M1 = L + (rl is an) / . 3 ;
 . 4              M2 = R- (rl is an) / . 3 ;
 . 5              IF (Check (M1)> = Check (M2)) R & lt = M2; / / here is more preferably larger 
. 6              the else L = M1;
 . 7          }

 

Guess you like

Origin www.cnblogs.com/InductiveSorting-QYF/p/10990470.html