3
Information Processing Letters 96 (2005) 93–95 www.elsevier.com/locate/ipl Tight bounds on plurality Nikhil Srivastava, Alan D. Taylor Department of Mathematics, Union College, Schenectady, NY 12308, USA Received 27 February 2005; received in revised form 3 June 2005; accepted 4 June 2005 Available online 28 June 2005 Communicated by L.A. Hemaspaandra Abstract We show that ( n1 2 ) pairwise equality comparisons are necessary and sufficient (in the worst case) to find a plurality in n colored balls. 2005 Elsevier B.V. All rights reserved. Keywords: Analysis of algorithms; Computational complexity 1. Introduction Given a finite set {x 1 ,...,x n } of colored balls, a strict plurality color is one that occurs more frequently than any other color, and a plurality color is one that occurs at least as frequently as any other color. In this paper, we consider the problem of picking a ball of a plurality color using only pairwise equality tests. That is, the only kind of operation we are allowed is to pick two balls and ask if they are the same color; in particu- lar, we cannot actually ‘look’ at the color of a ball. For strict plurality, it is easy to see that all ( n 2 ) comparisons are needed in the worst case. The corresponding question for majority has been studied in depth. Fischer and Salzberg [3] show that * Corresponding author. E-mail addresses: [email protected] (N. Srivastava), [email protected] (A.D. Taylor). 3n 2 2 comparisons are necessary and sufficient (in the worst case) to pick a majority representative or declare that a majority does not exist; Saks and Wer- man [4] establish that n ν(n) comparisons (ν(n) be- ing the number of 1s in the binary representation of n) will do if it is known beforehand that the input con- tains a majority color. Alonso et al. [2] derive a tight bound of 2n 3 8n 9π + O(log n) comparisons in the av- erage case. Determining the bounds for plurality was stated as an open problem in [1] and [5]. In this paper, we show that ( n1 2 ) comparisons are necessary and sufficient in the worst case. The difference between dealing with strict plurality and plurality is already clear in the case of three balls, where only one comparison is needed for the latter. That is, if we know that balls one and two are the same color, then either of them will defi- nitely represent a plurality (of size two or of size three, 0020-0190/$ – see front matter 2005 Elsevier B.V. All rights reserved. doi:10.1016/j.ipl.2005.06.004

Tight bounds on plurality

Embed Size (px)

Citation preview

Page 1: Tight bounds on plurality

l

ity in

Information Processing Letters 96 (2005) 93–95

www.elsevier.com/locate/ip

Tight bounds on plurality

Nikhil Srivastava, Alan D. Taylor∗

Department of Mathematics, Union College, Schenectady, NY 12308, USA

Received 27 February 2005; received in revised form 3 June 2005; accepted 4 June 2005

Available online 28 June 2005

Communicated by L.A. Hemaspaandra

Abstract

We show that(n−1

2)

pairwise equality comparisons are necessary and sufficient (in the worst case) to find a pluraln

colored balls. 2005 Elsevier B.V. All rights reserved.

Keywords: Analysis of algorithms; Computational complexity

ly

thisf aatckcu-or

enhat

,

t (inorer-

f-

ht

-

asowt inith

sededndfi-e,

1. Introduction

Given a finite set{x1, . . . , xn} of colored balls, astrict plurality color is one that occurs more frequentthan any other color, and aplurality color is one thatoccurs at least as frequently as any other color. Inpaper, we consider the problem of picking a ball oplurality color using only pairwise equality tests. This, the only kind of operation we are allowed is to pitwo balls and ask if they are the same color; in partilar, we cannot actually ‘look’ at the color of a ball. Fstrict plurality, it is easy to see that all

(n2

)comparisons

are needed in the worst case.The corresponding question for majority has be

studied in depth. Fischer and Salzberg [3] show t

* Corresponding author.E-mail addresses: [email protected] (N. Srivastava)

[email protected] (A.D. Taylor).

0020-0190/$ – see front matter 2005 Elsevier B.V. All rights reserveddoi:10.1016/j.ipl.2005.06.004

�3n2 � − 2 comparisons are necessary and sufficien

the worst case) to pick a majority representativedeclare that a majority does not exist; Saks and Wman [4] establish thatn − ν(n) comparisons (ν(n) be-ing the number of 1s in the binary representation on)will do if it is known beforehand that the input contains a majority color. Alonso et al. [2] derive a tig

bound of2n3 −

√8n9π

+O(logn) comparisons in the average case.

Determining the bounds for plurality was statedan open problem in [1] and [5]. In this paper, we shthat

(n−1

2

)comparisons are necessary and sufficien

the worst case. The difference between dealing wstrict plurality and plurality is already clear in the caof three balls, where only one comparison is neefor the latter. That is, if we know that balls one atwo are the same color, then either of them will denitely represent a plurality (of size two or of size thre

.

Page 2: Tight bounds on plurality

94 N. Srivastava, A.D. Taylor / Information Processing Letters 96 (2005) 93–95

nd,l-

ityn-

es-o--e

yplyofthe

in

areree

be

l,

ll

sto

orothrn

-e

r-

n,

fer

ed

of

or a

atsowat

bin

although we do not know which). On the other haif we know that balls one and two are different coors, then ball three will definitely represent a plural(either alone or in conjunction with ball one or in cojunction with ball two).

2. The lower bound

Theorem 1. Any correct algorithm for plurality mustuse at least

(n−1

2

)comparisons in the worst case.

Proof. We will construct an adversary that forc(n−1

2

)unequal comparisons; the adversary will sim

ply answer ‘no’ to all queries. Suppose an algrithm A stops afterc <

(n−1

2

)comparisons and de

clares that a ballxp has a plurality. Notice that therare

(n−1

2

)pairs among the remaining(n − 1) balls

x1, . . . , xp−1, xp+1, . . . , xn, so two of these balls, saxv andxw, must not have been compared. We simassert thatxv andxw are colored white and the restthe balls are distinct colors. This is consistent withadversary’s responses, but not withA’s output. ThusA does not work, and anycorrect algorithm must useat least

(n−1

2

)comparisons to pick a plurality ball.�

3. The upper bound

Theorem 2. The following algorithm correctly picks aplurality representative from n balls in at most

(n−1

2

)comparisons.

(1) Compare each pair of balls in{x3, . . . , xn} andplace them in bins so that two balls are in a biff they are the same color.

(2) Pick a bin and compare one ball from it withx2.If the comparison is equal, placex2 in the bin andmove on to the next step. Otherwise, if therebins left, try the next bin. If all comparisons aunequal andx2 does not get placed in any of thbins, create a new singleton bin forx2 and moveto the next step.

(3) Set aside all bins of maximal size—let theseB1, . . . ,Bd , each containings balls (say). Ifs = 1returnx1. Otherwise, comparex1 to a ball fromeach ofB1, . . . ,Bd−1. If any comparison is equa

returnx1. If they are all unequal, return any bafrom Bd .

Proof. Correctness. At the end of Step (2), the ballx2, . . . , xn have been distributed into bins accordingcolor; let these beC1, . . . ,Cm. If all bins are single-tons, thens = 1 and no two ofx2, . . . , xn are the samecolor. There are two possibilities as far asx1 is con-cerned: either all the balls are of different colors,x1 is the same color as one of the other balls. In bcases,x1 represents a plurality, so it is safe to retuthis as the answer without further comparisons.

Otherwise, assumes > 1, and consider what happens in Step (3). Ifx1 is the same color as one of thmaximal binsB1, . . . ,Bd−1, say Bm, then there ares +1 balls of this color and at mosts balls of any othercolor. Thusx1 (as well as any ball inBm) represents aplurality. On the other hand, ifx1 is not the same coloas any ofB1, . . . ,Bd−1, then one of the following occurs:

• x1 is the same color asBd . It is clear thatBd rep-resents a plurality.

• x1 is a different color from every other ball. Agaithere are no more thans balls of any color, soBd

represents a plurality.• x1 is the same color as some non-maximal binCl

with |Cl | < s. There are at most|Cl | + 1� s ballsof colorx1, soBd still represents a plurality.

In all cases,Bd represents a plurality, so it is sato return a ball fromBd as the answer without furthecomparisons.

Complexity. Step (1) uses exactly(n−2

2

)compar-

isons. We will count the number of comparisons usin Steps (2) and (3):

• If s = 1, then all bins are singletons at the endStep (1). Consequently, Step (2) takesn − 2 com-parisons, and Step (3) takes no comparisons, ftotal of

(n−2

2

) + (n − 2) = (n−1

2

).

• If s � 2, then at the end of Step (1) there areleastd − 1 bins of sizes, since at most one ball iadded to at most one bin in Step (2) and we knthere ared bins at the end of Step (2). Note thin Step (2),x2 is compared to only one ball fromeach such bin; in particular, it isnot compared toone other ball from each bin (because each

Page 3: Tight bounds on plurality

N. Srivastava, A.D. Taylor / Information Processing Letters 96 (2005) 93–95 95

ns

in

ty,

ity

go-

ar-

ing

hass � 2 balls). So the number of comparisoin Step (2) is at most

(number of balls in bins after Step (1)) − (d − 1)

� (n − 2) − (d − 1).

It is clear that the number of comparisonsStep (3) is at most(d − 1), and adding this to theprevious comparisons gives a total of at most(

n − 2

2

)+ (n − 2) − (d − 1) + (d − 1) =

(n − 1

2

)

as desired. �

References

[1] L. Alonso, E.M. Reingold, R. Schott, Determining the majoriInform. Process. Lett. 47 (1993) 253–255.

[2] L. Alonso, E.M. Reingold, R. Schott, Average-case complexof determining the majority, SIAM J. Comput. 26 (1997).

[3] M.J. Fischer, S.L. Salzberg, Solution to problem 81-5, J. Alrithms 3 (1982) 376–379.

[4] M.E. Saks, M. Werman, On computing majority by compisons, Combinatorica 11 (1991) 383–387.

[5] G. Wiener, Search for a majority element, J. Statist. PlannInference 100 (2002) 313–318.