Using the opponent to proof the number of comparison of the mediation problem

zhaozj2021-02-17  64

The five numbers of 5 times were as follows:

A tree chart T of the size between the five numbers. One node in t represents a number, and one edge represents the size of the two numbers it associated, the root of T is the median. It is obvious that one of T is determined by a game. In the following figure, if x is greater than Y, the node X is connected above the node Y and the X and Y have one side. In addition, * represents a general number, o indicates that the next one is about to be compared next time.

Step 1, first take two counts, the result is:

* | * O o *

Step 2, then take two other numbers, the result is:

OO | | * * * Step 3, according to the previous figure, the number of two marked O, the comparison result is only one case:

* / / * O | * o Step 4, according to the above figure, two of the two marked O, there are two cases:

* O * / / / / / o * o O | | | * * * Step 5, according to the above figure, two of the two tags O, there are two cases:

* * * / / / // // / / | / / | / | / | / / | | / o o | / | o O | || | * *

Step 6, according to the above figure, two of the two marked O, there are two cases:

* * * * * * / / / / | | X x * * | / | | * * * x x | | / / * * * * | *

Where X is median.

In fact, it can be proved that the neutral number of N numbers is required, at least 3 (N-1) / 2 comparisons, and there is an algorithm for an O (N) comparison.

The following describes how to use the opponent to demonstrate the method to prove the lower bounds of the median problem.

First introduce the "Adversary Argument" method.

When P represents the problem discussed, i represents the input of the problem, and a represents the comparative operation based algorithm T (A, I) representation of the solution problem, represents the computational time complexity of the input I algorithm A, then the function u (n = Min {Max {T (A, I)}, for Each I}, for Each A, is the best lower bound in worst case when the size is N when the input size is N. It is inherent. The best lower boundaries of the problem P are often difficult to calculate according to their definitions, because for a specific A, to get max {t (a, i)}, for each i is a difficult thing, let alone for everything A. Therefore, people often do not accurate U (N), but refer to the second, that is, find a f (n), it is not more than u (n) but close to U (n), so that f (n) ) Become a good lower bound of problem P.

The opponent argument method is an effective way to find F (N). Its basic idea is to construct a special input I 'to each A, make T (A, I') as much as possible, then on all A collection, ask T (A, I ') as possible The lower bound is f (n). This method passes F (N) <= min {t (a, i ')}}}}}}}}}}, for Each A <= min {Max {T (A, I)}, for Each I}, for Each A = U (N To ensure that f (n) is a lower boundary of the problem P, but also ensures that f (n) is a good lower bound by making T (A, I ') as much as possible.

The key to the method of argumentation is that there is a strategy of I 'that constructs all A-compliant I', that is, the opponent strategy. This strategy is gradually constructing an input I ', and the algorithm A is the result of obtaining a few corresponding to the comparison and judgment to make T (A, I') as much as possible. It should be noted that on the one hand, the opponent policy must be consistent, that is, it cannot be contradictory to ensure the existence of I '; on the other hand, the opponent strategy must also apply everything, because we need a collection of all A Seeking the lower bound of T (A, I '). As for the specific content of the strategy, it will vary depending on the problem. Even the same problem may have a variety of strategies, to get a good lower bound, you need a good strategy.

The prototype of the median problem is: 1 to n number, requires their median, ie the number of [(N 1) / 2].

Below we use the opponent to demonstrate the method of comparing the number of comparison of the mediation of the mediation to 3 (N-1) / 2 times.

Do not lose general, here it assumes that the N numbers give each other are different, and n is odd.

We use A to represent any of the comparative algorithms for solving the mediation problem. For any given input I, the algorithm A has been determined where (N-1) / 2 numbers of I are larger than the median number and (N-1) / The 2 counts are less than the median. We are called the number of meditile numbers, and the number of median is lower than the number of lower numbers. Obviously, the algorithm finally dispenses (N-1) / 2 upper and (N-1) / 2 lower numbers from i, relying on a series of games of the "organization". A number is finally determined to be the top number, or once directly with the median game, it has won it, either with another superior number and winning it; Similarly, a number is finally determined to be a lower number, or Once directly competed with the median, it will be lost to it, or it has been played with another lower part and lost it. We call the algorithm is the superior number or the lower number of games, as well as a critical competition between the upper number or the lower number and the median number; regarding that the algorithm is the upper number and the lower number of two The game between numbers is a non-critical competition. Note that only critical matches can make us useful information, non-critical competitions do not allow us to obtain useful information. If N1 (A, I), N2 (A, I), and T (A, I) respectively indicate the number of key than the key ratio of the loser I algorithm A, the number of non-critical competitions and calculation time complexity, then we are obvious There are T (A, I)> = N1 (a, i) n2 (a, i) Our goal is to give a computation time of the median problem, that is, for all algorithms a, max {t (a , I)}, a lower bound, and I hope the value of this lower bound is large. To this end, we use the opponent to demonstrate the method. For any given algorithm A, assume that his input is i, set M whether it is not in I, we will start from i, construct a certain input I '. Because the non-critical competition can't give us useful information, it is "unused" game, in order to get as much T (A, I '), our constructed I' should make N2 (A, I ') as much as possible . Every two numbers in I use n, n ', L, s, s, and e to expressed N, N', L, S, S and E, respectively, with N, N ', L, S, S, and E in the state of comparing (before participating).

★ N: The number did not participate in the competition, and not the current number of the currently did not participate; ★ n ': The number is the only number of the currently participating in the competition; ★ L: The number has participated in the competition, And its value is greater than m; ★ S: This number has participated in the game, and its value is less than m; ★ E: The number has participated in the game, and its value is M.

The opponent strategy taken is shown in Table 1. Note that the opponent strategy in Table 1 is consistent, because numbers in I 'are only when they participate in the competition (ie, N' in front of the X, Y ") will be modified X, Y. The value, once the value of x, y is modified, will no longer be modified when the game is participated in the game. Table 1 The key to the opponent strategy is: When the X, Y first participation in the competition, if the game may become a critical competition, modify the value of X and Y, make the game as a non-critical competition; in the last When a number of participation, his value is modified to the value of the predetermined median M.

Table 1 Hemonographic problem

======== ======= ===================================================================================================================================================== = =============================================================================================================================================================================================================== ------- ------- | Counter 对 | | Game Type --------------- | X | Y | | | x | Y | ======== =========================================================================================================================================================================== == ============ ======= ========

======== ======= ===================================================================================================================================================== = ============ ======= ======= | n | n | If x> m and Y> M, reduce Y, make Y M; Non-critical | L | s || | ------------------------------- -- -------- ------- ------- | | If x, Y> M, the x, y | Non-critical | s | L || | --------------------------------- --------- - ------- ------- | | | If x> m and Y

========= ============ ======= ======= | s | s | does not change X, Y | Key | s | s | ========= ================================== ========= ============ ======= ======= | E | E | This situation is impossible | | - | - | ======== ==================================== ===== ============ ======= ======= | n '| n' | This situation is impossible | - | - | - | ======== ==================================== ===== ============ ======= =======

======== ======= ===================================================================================================================================================== = ========================================================================================================================================================================================================================================= Key | L | E | ======== ================================== =============================== ======= | n '| L | does not change the value of Y, The value of the X is M | Key | E | L | ======== ======= ================== ================ ============ ======= ======= | s | n ' Do not change the value of X, the value of Y is M | Key | s | e | ======== ======= =========== ======================= =======

===== =================================================================================== ======= =========================================== ============ ======= ======= | n | n '| If X M, the value does not change the value, the value of Y is M | critical | L | e | ======== =================================== ===== ============ ======= =========== | N | If Y M, the value of Y is not changed, the value of X For M | Key | L | L | ======== =============================== ==

========= ============ ======= =======

======== ======= ===================================================================================================================================================== = ============================================================================================================== ; | Non-critical | s | L | ======== ================================ =========== ============ ======= ======= | L | N | If Y> M , Then reduce Y, make Y

======== ======= ================================================================================================================================= === ======= ================================= ==== ======== ================ | n | s | If x M, increase X, make X> M; | Non-critical | L | S | ======== ====================================================================================================================================================================================== ==== ============ ================= | s | n | If Y M; | Non-critical | s | L | ======== ======= ====================== ============= ============ ======= =======

======== ======= ===================================================================================================================================================== = ============ ======= ======= | n | E | This situation is impossible | - | - | - | = ======= =========================================== ============ ======= ======= | E | N | This situation is impossible to appear | - | - | - | === ===== ======= ========================================================================================================================================================================================== ========== ======= ======= | L | E | does not change X, Y | Key | L | E | ==== ==== ======= ================================= === =========

= ======= ======= | E | L | does not change X, Y | Key | E | L | ======== ==== === ================================= ================================================================================================================================================================================================= ======= ======= | s | e | does not change X, Y | Key | s | e | ======== ===== == ================================= ============= ======= ======= | E | S | does not change X, Y | Key | E | s | ======== ====== = ================================= =============================================== ====== ========

According to the strategy of Table 1, the number in I 'is only modified when it is in the first competition, further, for the N number of I', where at least N-2 is attentive Non-critical competition. It is noted that N is odd, so the algorithm A is at least (N-1) / 2 times in the game "organized" "organized" according to Table 1, and N-1) / 2 times, namely N2 (A, I ') > = (n-1) / 2 ------ (1) Let's consider the boundaries of N1 (A, I ') for the same I'. As previously mentioned, the algorithm A must identify the (N-1) / 2 upper portion and (N-1) / 2 lower numbers of I '(N-1) / 2 lower numbers. It is more specific, and the algorithm A must recognize a tree diagram T of the size relationship between the N numbers of I '. One node in t represents one of I ', and one edge represents the size of the two numbers it associated, the root of T is the median. Obviously the one of T is determined by a game, but because a tree of n-nodes has N-1, t at least N-1 game can be determined, and these games must be Key game. Thus, we have N1 (A, I ')> = N-1 ------ (2) Synthesis (1) (2) can be known: max {t (a, i)}> = t (A, I ') = N1 (A, I') N2 (A, I ')> = 3 (N-1) / 2 to obtain a comparative number of median problems to 3 (N-1) / 2. As for the worst case, the algorithm of the selection of the kth element is compared, it is more troublesome, and it will not be said to be temporary (typing is too tired ~~)

转载请注明原文地址:https://www.9cbs.com/read-30811.html

New Post(0)