Finding non-minority balls with majority and plurality queries
aa r X i v : . [ m a t h . C O ] D ec Finding non-minority balls with ma jority and pluralityqueries
Huilan Chang a,b
D´aniel Gerbner c Bal´azs Patk´os c a Department of Applied Mathematics, National University of Kaohsiung, Taiwan, R.O.C. b Scientific Multi-simulation Research Center, College of Science,National University of Kaohsiung, Taiwan, R.O.C. c Alfr´ed R´enyi Institute of Mathematics, Hungarian Academy of Sciences
December 24, 2018
Abstract
Given a set of n colored balls, a majority, non-minority or plurality ball is one whosecolor class has size more than n/
2, at least n/ q of the following form: the answer to a majority/plurality query Q is a major-ity/plurality ball in Q or the statement that there is no such ball in Q . The basic instance of the Majority Problem is the following. We are given n balls with anunknown 2-coloring. We can pick two balls and ask if they have the same color or not as a query.Our goal is to find a so-called majority ball, which is a ball of a color class of size greater than n/ n − b ( n ), where b ( n ) is the number of 1s in the binary form of n . Earlier Fisher and Salzberg[6] showed that if the number of colors is also unknown, then ⌈ n/ ⌉ − Definition 1.1.
In a set X of balls, a ball x ∈ X is a majority ball if there are more than | X | / x in X ; x is a non-minority ball if there are at least | X | / x in X . A ball x is a plurality ball if there are more balls of the color of x in X , than of anyother color. A ball x is an almost plurality ball if it is either a plurality ball, or a non-minorityball.Note that a ball is almost plurality but not plurality only if there are only two colors, | X | iseven and both color classes have size | X | /
2. Note furthermore that if there are only two colorsin X , the majority and the plurality balls are the same.Gerbner, Keszegh, P´alv¨olgyi, Patk´os, Vizer and Wiener [8] considered the following variant.The answer to a query Q is YES and a majority ball inside Q if such a ball exists, and NO ifthere is no majority color inside Q . They observed that in the case of two colors, using thesetype of queries of odd size, one can never claim there is no majority ball, as the answers arealways YES, thus we can never rule out the possibility that there is only one color. This meanswe cannot solve the majority problem in the original sense. However, they proved that one canalways show a non-minority ball after O ( n ) queries of size 3. Definition 1.2.
For a majority query Q the answer is NO if there is no majority ball in Q ,otherwise the answer is YES and a majority ball x is also presented.For a plurality query Q the answer is NO if there is no plurality ball in Q , otherwise theanswer is YES and a plurality ball x is also presented.Sometimes we will call an answer consisting of YES and a ball simply YES answer, when wedo not care which ball was shown.We will consider the following functions. The first letter M or P denotes that we use majorityor plurality queries. The second letter is B if we want to find a non-minority ball in X , and C ifwe try to find an almost-plurality ball. Then in brackets we write the size | X | of the underlyingset, the size of the queries and the number of colors.Using the above notation the results of [8] can be summarized as M B ( n, ,
2) = O ( n ), M B ( n, k,
2) = O ( n ) and M B ( n, k + 1 ,
2) = O ( n ). Note that in case of two colors, M and P are the same, while B and C are the same as well. It was conjectured in [8] that M B ( n, k + 1 ,
2) = O ( n ). Here we will prove this. Moreover, we extend all these results to morecolors. 2 heorem 1.3. For any fixed q and c , there exist an integer n = n ( q, c ) and a constant K = K ( q, c ) such that if n ≥ n holds, then we have M B ( n, q, c ) , M C ( n, q, c ) , P B ( n, q, c ) , P C ( n, q, c ) ≤ Kn.
Note that for n ≤ n there may not be a solution at all. For example if the answer isNO to every majority query, it only means every color class has size at most q/
2, but doesnot help find an almost plurality ball. We prove parts of this theorem separately. In Section2 we prove
M B ( n, k + 1 ,
2) = O ( n ), in Section 3 we prove M B ( n, k + 1 , c ) = O ( n ) and M B ( n, k, c ) = O ( n ), while in Section 4 we prove P B ( n, q, c ) = O ( n ). In all cases the proofimplies the same bound for finding an almost plurality ball. We finish the paper with someremarks in Section 5. First we list the results of Gerbner, Keszegh, P´alv¨olgyi, Patk´os, Vizer and Wiener [8] that weuse. They introduced the following reformulation. The two colors are denoted by 0 and 1. Inthis case a median is always a non-minority ball.
Theorem 2.1 ([8]) . (i) By asking all the queries of size k + 1 , we can find a non-minority ball. (ii) By asking all the queries of size 3, we can find a monotone ordering of the balls (notethat there is no way to decide if the ordering is monotone increasing or decreasing). (iii)
If the answer to a query { x, y } can be any of the two valid statements out of x ≤ y , y ≤ x or x = y , then by asking linearly many queries, we can find a median element. We will also use the following simple algorithm from [8]. We call it Algorithm WINNER-OUT. We start with a query of size q , set aside the answer ball and replace it by a new ball.Then repeat this procedure till all the balls are used (or we get a NO answer, if it is possible).After that, there is a set S of q − S belongs to one of the largest color classes in S . In particular, in case q = 2 k + 1and c = 2, the set S has the following property: either there are k balls in S of both colors, orevery ball outside S has the same color, and it is the majority color in S . Theorem 2.2.
M B ( n, k + 1 ,
2) = O k ( n ) .Proof. Observe that we can assume n is large enough, as we are interested only in the order ofmagnitude.First we apply Algorithm WINNER-OUT to obtain a set S . Then we apply the same to X \ S to obtain S , and so on till we obtain S m with m = 8 k . This is the first phase of thealgorithm. Let S = S mi =1 S i , then we have that a non-minority ball in X \ S is a non-minorityball in X . Indeed, either every S i is balanced, or all the other balls are of the same color, andthat is a non-minority color as n is large enough.3rom now on we will assume that every S i is balanced, then by the above it is enough toshow a non-minority ball in X \ S under this assumption. In the second phase of the algorithmwe will find k balls of one color and k balls of the other color. We will only use queries that arecompletely inside S , thus constant many queries.Let us first take an arbitrary x ∈ S , and remove it from S . Then we can find a non-minorityball y in S \ { x } using (i) of Theorem 2.1. Then y and x have different colors, as S is balanced.We apply this for every vertex, this way each ball has a pair of the other color. Let G be thegraph with edges corresponding to these pairs. Case 1.
There is a ball x with degree more than 2 k in G .Without loss of generality x ∈ S . Then we delete S . There is a neighbor y of x in S \ S .Similarly to the above process, we can find a pair x for y in S \ S by finding a non-minorityball in ( S \ S ) \ { y } (we can do this, as S \ S is balanced). Note that this pair may or maynot be in G as an edge.Without loss of generality, x is in S . Then we also delete S , x has a neighbor y amongthe remaining balls, and we can find a pair x ∈ ( S \ S ) \ S for y . We repeat this proceduremultiple times. After deleting S k − , there is still at least one neighbor y k − of x remaining, andit has a pair x k − among the remaining vertices. This way we found k distinct balls of the colorof x , and we have already found more than 2 k balls of the other color, thus we are done withthe second phase. Case 2.
Every ball has degree at most 2 k in G .Observe that every component of G is bipartite. If any component has at least k vertices onboth sides, we are done with the second phase again. Thus every component has at most 2 k vertices, hence there are at least k − k − k − A be the set of the 2 k − S ′ be the set we obtain by deleting from S every S i that contains any ball from A . From the sets S j not deleted, we form (8 k − k + 2) / S j and S j , and askevery query that contains A and three balls from S j ∪ S j . Case 2.1.
For some pair S j and S j , the answer is always one of the three balls from S i ∪ S j .Then we found a majority ball among those three, thus we can find a monotone ordering ofthe balls in S i ∪ S j by (ii) of Theorem 2.1. The first k balls of this ordering are of the samecolor, and the next k balls are of the other color, finishing the second phase. Case 2.2.
For every pair S j and S j , at least one of the answer balls is an element of A .Then there is a ball x in A that occurs as an answer to at least (8 k − k + 2) / (4 k − ≥ k queries that all contain A but are disjoint otherwise. Let B be the set of 6 k balls avoiding A from 2 k such queries, then there are at least 4 k balls in B of the color of x . In particular a non-minority ball y of B is of the color of x . Similarly, a non-minority ball y in B \ { y } also sharesa color with x , and so on. This way we can find 2 k balls of the color of x . Their neighborhood4n G has size at least k , otherwise a vertex in their neighborhood would have degree more than2 k . This way we found k balls of the other color, finishing the second phase.In the third phase, we denote the colors by 0 and 1, following [8]. We are already given k balls of color 0 and k balls of color 1, from S . Let us consider two balls x, y ∈ X \ S . We asktwo queries: x and y together with k balls of color 0 and k − x and y together with k − k balls of color 1. • Answer x to the first query means x ≤ y , answer y means y ≤ x , answer 0 means at leastone of x and y has color 0, while answer 1 means they both have color 1, which implies x ≤ y . • Similarly, for the second query the answer tells either x ≤ y , or y ≤ x , or that at least oneof x and y has color 1. Combining the two answers, we obtain either x ≤ y , y ≤ x or x = y .Thus (iii) of Theorem 2.1 finishes the proof. Theorem 3.1.
For any fixed k and c , there exist an integer n = n ( k, c ) and a constant K = K ( k, c ) such that if n ≥ n holds, then we have M B ( n, k + 1 , c ) , M C ( n, k + 1 , c ) ≤ Kn.
Proof.
Our algorithm consists of three phases. In the first phase we use Algorithm WINNER-OUT until we find a NO answer and then the first phase is over. If during Algorithm WINNER-OUT we get only YES answers, let S be the set of balls never appearing as answer. Then eitherthere are k balls of one color and k balls of another color in S , and all the other balls are ofthese two colors, or all the other balls have the same color. In both cases we can delete S , andfind a non-minority ball among the other balls using O ( n ) queries by Theorem 2.2. That ball isa non-minority and thus an almost-plurality ball in X as well.Hence we can assume we found a NO answer to a query Q . In the second phase our goal isto find k balls of one color, k balls of another color and a ball of a third color. Let q = 2 k + 1.We partition the set X \ Q into subsets A , . . . , A ⌊ ( n − q +1) /cq ⌋ of size cq or cq + 1. Then for every i we ask all the q -subsets of A i ∪ Q . Observe that for a set B ⊂ A i ∪ Q of size k + 1, there isa majority ball in every query that contains B if and only if B is monochromatic. Indeed, forevery color there are at least k + 1 balls avoiding that color in Q , thus we can extend B to a setof size q without majority. Thus we can identify all the color classes of size at least k + 1 inside A i ∪ Q .If there are two color classes of size at least k + 1 in A i ∪ Q for some i , we can take k ballsfrom each and a ball from another color to obtain the desired configuration. Assume that forevery i there is only one such color class B i in A i ∪ Q . We are going to compare the color of B i and B j . In order to do that, we take k balls for B i and k balls from B j and ask every query thatconsists of these 2 k balls and one ball from Q . The answer is always YES if and only if B i and B j are of the same color. 5f we find B i and B j are of different colors, the query that was answered NO contains thedesired configuration. Otherwise with linearly many queries we obtain that all the B i ’s are ofthe same color, and that is a non-minority, thus almost plurality color.In the third phase we are given, say, k blue balls, k red balls and a green ball. Then asking1 green, k blue and k − x , the answer shows if x is blueor not. Thus with O ( n ) queries we find all the blue balls and similarly all the red balls. Amongthe remaining balls, we take a set R of size ( c − k + 1, and ask all the queries consisting of k blue balls and k + 1 balls from R . As R contains k + 1 balls of the same color, we get a YESanswer, finding a monochromatic set of a third color. Taking k of those balls, k − c − k + 1 balls. If there are less than that many balls altogether in the remaining colorclasses, those cannot be non-minority/almost plurality if n is sufficiently large, thus it is enoughto check those classes we have already completely identified. This finishes the proof. Theorem 3.2.
For any fixed k and c , there exist an integer n = n ( k, c ) and a constant K = K ( k, c ) such that if n ≥ n holds, then we have M B ( n, k, c ) , M C ( n, k, c ) ≤ Kn.
Proof.
First we obtain a YES answer to a query Q , by asking all the (2 k )-subsets of a set ofsize ck + 1. Then we run Algorithm WINNER-OUT starting with Q ; assume that the queriesfollowing Q are Q , Q , . . . and so on.Let us consider first the case that Algorithm WINNER-OUT terminates after only YESanswers. We claim that in this case all the answer balls are majority balls. Indeed, the answerballs to Q i and Q i +1 have to be of the same color, as Q i contains at least k + 1 balls of a color,then Q i +1 contains at least k balls of that color, thus it cannot be a minority color. Thus the n − q + 1 answer balls are of the same color and they form majority.Assume now that during Algorithm WINNER-OUT we obtain a NO answer, first to a query Q j . Let the color of the answer ball x to the previous query Q j − be blue. Then Q j − containsexactly k + 1 blue balls. Let us ask all the queries of the form Q j − \ { x } ∪ { y } for y Q j − .The answer is NO if and only if y is not blue. This way we can identify all the blue balls not in Q j − . Let z be the ball in Q j \ Q j − . Then we know z is not blue. Let us ask the queries of theform Q j − \ { x } ∪ { z } for every x ∈ Q j − . The answer is YES if and only if x is not blue. Thisway we can completely identify the blue color class.If there are more than n/ ck + 1)-set S ofnon-blue balls as n is large enough. We ask all the ( k + 1)-subsets of S together with k − k + 1 balls have the same color. This way we identifyone color class of size at least k + 1, say red, in S . Then we ask all the queries consisting of k − k red balls and a ball of unknown color, to find all the red balls. Then repeat it with athird color, and so on. We can do that as long as there are more than ck balls. Hence the number6f unidentified balls is at most ck . Therefore, if n is at least c k , we completely identified thetwo largest color classes, and that is enough to decide if there is a non-minority/almost pluralityball and show one such ball. Theorem 4.1.
For any fixed q and c , there exist an integer n = n ( q, c ) and a constant K = K ( q, c ) such that if n ≥ n holds, then we have P B ( n, q, c ) , P C ( n, q, c ) ≤ Kn.
Proof.
We proceed by induction on c . Observe that if c = 2, then majority and plurality queriesare the same. Also, a ball is non-minority if and only if it is almost plurality. Therefore Theorem2.2 yields the base case of the Theorem 4.1.The algorithm consists of multiple phases. In the first phase our goal is to find a query Q that is answered NO and a ball x Q that belongs to one of the largest classes in Q . In order todo that, first we find a YES answer to a query Q . It is doable by asking all the q -subsets of aset of size qc . Then we run algorithm WINNER-OUT starting with Q . If we get a NO answerto a query Q at any point, the previously removed ball belongs to one of the largest color classesin Q .Assume all the answers are YES. Let Q be the last query of algorithm WINNER-OUT, andlet y be the answer ball to Q and S = Q \ { y } . Let us call the color of y blue. Observe thatevery ball not in S belongs to one of the largest color classes in S .Then we ask all the queries of the form Q ∪ { u } \ { v } , where v ∈ Q , u Q . If u is blue,then the answer is YES for every v . If u belongs to another of the largest color classes in S , andthere are at least three colors altogether, then the answer is not always YES. Hence if the answeris always YES, there are two possibilities. In both cases there are at most two colors outside S ,and those colors have the same number of balls inside S , thus we can use Theorem 2.2 to find anon-minority, thus almost plurality ball in the entire set X of balls.Thus we can assume we obtain a NO answer to Q = Q ∪ { u } \ { v } . Moreover, we can identifyevery blue ball outside Q as a ball x ∈ X \ Q is blue if and only if the answer to Q ∪ { x } \ { v } is yes for every v ∈ Q . If there is no such ball, we can delete Q . As all the colors appearingin balls outside Q belong to the largest color classes in S , they have the same number of ballsinside Q . As there is no blue ball in X \ Q , the number of colors used on balls in X \ Q is atmost c −
1. So, by the induction hypothesis, we can find a non-minority and an almost pluralityball in X \ Q with O ( n ) queries. It is a non-minority/almost plurality ball in X , because bluecannot be a non-minority color, nor an almost plurality color since n is large enough. Thus wecan assume there is a blue ball x outside Q .In the second phase of the algorithm, our goal is to completely identify the color class of theball x that we found in the first phase. Let us call it blue. First we ask all the queries of the7orm Q ∪ { x } \ { z } with z ∈ Q . If z is blue, the answer is obviously NO, while otherwise YES,thus we find all the blue balls inside Q . Now we ask the queries of the form Q ∪ { y } \ { z } , where y Q and z ∈ Q . If y is blue, the answer is NO if and only if z is blue. If y is not blue, thenthe answer may still be NO in the case z is blue (if there are at least 3 largest color classes in Q ), but it is also NO in case z is from another one of the largest color classes in Q . Thus we canfind all the blue balls.In case if there are less than ⌈ q/ ⌉ blue balls altogether, we delete all the blue balls and repeatthis argument to identify another color class. We can do this if we have qc other balls. We repeatthis until we identify a color with at least ⌈ q/ ⌉ balls (it is doable if n > qc + ( c − ⌈ q/ ⌉ ).Without loss of generality we can assume that there are at least ⌈ q/ ⌉ blue balls.We continue with the third phase, where our goal is to find ⌈ q/ ⌉ balls of another color class.We take a set Z of cq non-blue balls and we ask all of its subsets T of size ⌈ q/ ⌉ together with aset B of ⌊ q/ ⌋ blue balls. If q is even, then the answer tells us if the q/ q/ Z . If q = 2 l + 1 is odd, then the answer to T ∪ B is NO if and only if T contains exactly l ballsof the same (non-blue) color. So if the answers are YES to all the queries T ∪ B , then Z ismonochromatic, so again we are able to identify all large color classes of Z .Suppose that the answer to T ∪ B is NO and T contains l green balls. Then if a ball z ∈ Z \ T is green, then for t ∈ T , t is non-green if and only if the query { z } ∪ ( T \ { t } ) ∪ B answers YES(the answer ball must be in { z } ∪ ( T \ { t } )); if z is non-green, then for t ∈ T , t is green if andonly if the query { z } ∪ ( T \ { t } ) ∪ B answers YES (the answer ball must be in B ). Then we canidentify all green balls in Z . Considering all queries T ∪ B that answer NO, we can identify acolor class of Z that has size at least ⌊ q/ ⌋ (in fact, we can identify all such color classes in Z ).In the fourth phase our goal is to identify all the balls of the color class, say red, that wefound in the third phase. We ask ⌈ q/ ⌉ − ⌊ q/ ⌋ blue balls and a ballof unknown color. This tells if the unknown ball is red or not, completely identifying all the redballs.After that we can similarly identify all the color classes, as long as there are at least cq balls. If there are less than cq balls altogether in the remaining color classes, those cannot benon-minority/almost plurality as n is large enough, thus it is enough to check those classes wehave already completely identified. This finishes the proof. Note that we did not try to optimize the constant factor in the algorithms presented in thispaper. However, it is unlikely that our methods could lead to strong bounds.There are results for majority and plurality problems where the algorithm has to be non-adaptive, i.e. all the queries have to be asked at the same time, before learning any answers. Incase of two colors, a quadratic upper bound for queries of even size and a cubic lower bound for8ueries of odd size was given in [8].Another variant studied in [8] is the following. A ball is an α -ball in X if there are at least α ( | X | −
1) other balls of the same color in X . Thus a 1 / Q is an α -ball in Q (or No if it does not exist), then we may not beable to find an α -ball in the set of all balls. A natural question, studied in [8], is the following.For what β can we find a β -ball using only α -queries? It would be also interesting to extendthese investigations to more colors. Acknowledgement : The research of Huilan Chang was supported by the grant MOST106-2115-M-390 -004 -MY2. Research of D´aniel Gerbner and Bal´azs Patk´os was supported bythe National Research, Development and Innovation Office - NKFIH under the grants K 116769and KH 130371, by the J´anos Bolyai Research Fellowship of the Hungarian Academy of Sciencesand the Taiwanese-Hungarian Mobility Program of the Hungarian Academy of Sciences.