Opponent argument, generally used to give the lower bound of the problem. If you use $p$ to represent the problem that you are discussing, $I $ to indicate the input of the problem, $A $ represents the algorithm based on the comparison operation to solve the problem, $T (\,a,\,i) $ represents the computational time complexity for the input $i$, the algorithm $a$, then the function $u (n) =min\{max\{t (a,\,i) \ },\text{for each} i\},\text{for each} a$ represents the problem $p$ the worst-case best time lower bound when the input size is $n$, which is inherent to the problem.

The basic idea of opponent argumentation is to construct an input special input $i ' $ for each $a$, make $t (A,\,i ') $ as large as possible, and then on all $a$ sets, Seek $t (A,\,i ') $ as far as the lower Nether as $f (N) $. The key to the opponent argumentation method is a set of $i ' $ strategy for all $a$ applicable constructs, that is, the opponent strategy, gradually constructs an input $i ' $, so that the algorithm $a$ if want to achieve the desired results, to do as many times as possible to compare and judge, thereby making $t (A,\,i ') $ as large as possible. It should be noted that on the one hand, the opponent strategy needs to be consistent, that is, can not contradict, to ensure the existence of $i ' $; On the other hand, the opponent strategy must also be applicable to all $a$, because we need to find $t (a,\,i ') $ lower bound on all $a$ sets.

**1. Find $2^{nd}$ Largest number**

We know that finding the maximum value of an element in an array requires at least a $n-1$ comparison, so what is the second largest? Brute force algorithm is to find a maximum Bai, but also $n-2$ times comparison, a total of $2n-3$ times comparison. At first glance looks good, but through the analysis of the opponent argument, the total number of comparisons can be reduced to $n+\lceil \log n \rceil-2$ times. How to?

In fact, the so-called second-largest element, should be in comparison only to the largest element, that is, only with the largest element than the loser can be. What we're going to say is that the second largest element we're looking for is in the $\lceil \log n \rceil$ elements that are compared to the largest element.

In the opponent argument, we choose 22 pairs each time, and then compare, so that the comparison after each match, the data size is reduced by half, that is, a total of $\lceil \log n \rceil$ wheel comparison, the loss of these to the maximum number of elements to take out, Make a Find-max, the overhead is $o (\lceil \log n \rceil) $ you can find the second largest!!

This is not a rigorous argument, it just proves that the sector is attainable, and the details are shown here.

**2. Find Max and Min**

It is also possible to use the opponent's argument to conclude that the minimum number of comparisons is $\left\lceil \frac{3}{2}n \right\rceil-2$, which is also shown in the link above

Below, we say how to do it, first 22 paired, a total of $\left\lceil \frac{1}{2}n \right\rceil$ comparison, the winner and the loser in the two groups, and then in two groups to select Max and Min, the price is $2\ Times (\left\lceil \frac{1}{2}n \right\rceil-1) $, so you can get Max and min, the total number of comparisons is $\left\lceil \frac{3}{2}n \right\rceil-2$.

**3. Matrix Search**

This problem has a very good premise, that is we give the $n\times n$ matrix is ordered, in such conditions, we want to find an element $x$ in the matrix, through the opponent argument, we can do linear time $o (n) $.

The first is a less efficient method, with a binary search for each row, up to $n$ rows, so the complexity is $o (n\log N) $

Here is a super-witty algorithm, <step-wise linear search > start at the top right, each time the search value $x$ and the upper right corner of the value comparison, if greater than the upper right corner of the value, the direct removal of 1 rows, otherwise, 1 columns are removed. As shown below, the process of finding $x=28$ in a matrix is demonstrated

In the opponent argument, we only need to construct as much as possible a number to find, but always do not meet the conditions, such as the situation can not find the worst case, and the shortest time is the use of this <Step-wise> method. This is the most common way to look at the two-time diagonal, the total number of probes is $n+n-1=2n-1$, so the complexity is $o (n) $.

**4. Horses Select $1^{st}, 2^{nd}, 3^{rd}$**

Problem Description: There are 25 horse races, and there are only 5 tracks in a field, and now you need to pick the fastest top three with as few matches as possible.

First of all, at least every horse has a chance to run, so at least play 5 games first, and arrive at a total of 5 group rankings of 25 horses. Then, take each group of champions out for a walk, and after the 6th, we'll be able to pick the champions, and we know that the last two of the sixth game must not be the top three, because they will at least lose to the 3 horses known. Along with it, the stables in the group of two impossible races were impossible, and the group was the first to be defeated. (Gee, that year Hong Corge group first but did not qualify is such a thing!!! So the question is, is it going to be done with just one game? The answer is: YES!!

Let's start with the competition,

Each line, from fast to slow sort, without losing its generality, the group first is $x1,\ x=a,b,c,d,e$, we assume that the sixth game $a1>b1>c1>d1>e1$,$>$ Express a quick comparison. Then $a1$ must be the champion! The following may be the second and third of the only possible $a2,\,a3,\,b1,\,b2,\,c1$ these 5. Why can't it be $c2$? Because $c2$ at least to $c1$, and $c1$ and at least lost to $a1$ and $b1$, then $c2$ 's best result is only four, the other situation is similar analysis.

So in this seventh game, walk a walk $a2,\,a3,\,b1,\,b2,\,c1$, there is a second, third place produced.

The three analysis methods of the Mid-exam of < algorithm This is the end of the flower! >

[Algorithm Tutorial] Adversary Argument, opponent argument