Should Tables Be Sorted?

Transcription

1 Should Tables Be Sorted? ANDREW CHI-CHIH YAO Stanford Umversay, Stanford, Cahforma ABSTRACT Optmaahty questions are examined m the following information retrieval problem. Given a set S of n keys, store them so that queries of the form, "Is x E S?" can be answered quickly It is shown that m a rather general model including all the commonly used schemes, [lg(n + I)] probes to the table are needed m the worst case, prowded the key space is sufficiently large The effects of smaller key space and arbitrary encoding are also explored KEY WORDS AND PHRASES mformauon retrieval, lower bound, optmaahty, query, Ramsey's theorem, search strategy, sorted table CR CATEGORIES. 3 74, 4 34, 5 25, Introduction Given a set S of n distinct keys from a key space M = (1, 2,..., m}, a basic information retrieval problem is to store S so that membership queries of the form, "Is j in S?" can be answered quickly. Two commonly used schemes are the sorted table and the hash table. In the first case, a query can be answered in [lg(n + 1)1 probes by means of a binary search. ~ The hash table scheme has a good average-case cost, but requires O(n) probes in the worst case for typical hashing schemes. Looking at various alternative methods, one gets the feeling that ~log n probes must be necessary in the worst case, if the key space M is large and we only use about minimal storage space. Our purpose is to study the truth of this statement. The question is nontrivial, as the existence of hashing suggests the possibility of schemes drastically different from, and perhaps superior to, the sorted table. Before presenting technical results, let us try to put the subject of this paper in perspective. In the literature, efficient methods have been devised to perform various primitives in data manipulations [1, 8, 20]. For example, a sequence of n "DELETE," "INSERT," "MIN" instructions can be performed in O(n log n) time. In recent years, lower bounds to the complexity of these problems have also begun to receive attenuon (e.g., [7, 9, 15, 18]). Since effficient data structures may utilize the full power of a random-access machine (e.g., [20]), it is of special interest to study the complexity problems in general models that are equipped with some address-computing capabilities. This paper is one step in that direction, studying perhaps the simplest of such data structuring problems. It Is hoped that one can derive interesting results for other problems in similar frameworks. (For related study regarding bitwise-random-access machines, see [5, 6, 10].) lg denotes logarithm with base 2 Permission to copy without fee all or part of this material is granted provided that the copies are not made or dlstnbuted for direct commercial advantage, the ACM copyright notice and the title of the publication and its date appear, and notice is given that copying is by permission of the Association for Computing Machinery To copy otherwise, or to republish, reqmres a fee and/or specific permission This research was supported in part by the National Science Foundation under Grant MCS Author's address: Department of Computer Science, Stanford University, Stanford, CA ACM ll/81/ $00.75 Journal of the Association for Computing Machinery, Vol 28, No 3, July 1981, pp

2 616 ANDREW CHI-CHIH YAO sorted table 11,2t, {2,3} ~ ~ {2,31 {1,3} = {1,31 2 probes cyclic table " L.!_12_1 - L I2_I -l_2_u 1 probe FIG 1 The sorted table is not optzmal for n = 2, m = 3 2. The Wisdom of Using Sorted Tables In this section we show that for large key space, [lg(n + 1)] probes are required to answer the membership problem in a rather general model. This model encompasses all common schemes such as hashing, sorted tables, and linked list structures. For clarity, we first prove the result m a simplified model. The general result will be given in Theorem 1'. The Basic Model. Let the key space be M = (1, 2... m }. We are interested in storing n distinct keys of M into a table of size n. A table structure J-specifies how any particular set of n keys are to be placed in the table T. A search strategy 5~ corresponding to J-specifies, for any given key K, how to perform a series of probes TOO =?, T(iz) =?... into the table T, until one can claim whether K is in T or not. The search strategy ls fully adaptive, in the sense that each probing location can depend on K and on all the previous probing results. The cost c(j, 5 e) of a (table structure, search strategy) pair is measured by the number of probes needed in the worst case. The complexityf(n, m) is the minimum cost achievable by any such pair. Clearlyf(n, m) _< [lg(n + 1)]. To get some feehng for possible improvements over the sorted table scheme and on its ultimate limitation, we look at the simple case n = 2, m = 3. It is easy to see that two probes are needed to decide whether K = 2 is in T if a sorted table is used. However, the "cyclic" table in Figure 1 allows us to answer any query in just one probe, as the first entry of T determines the entire table. Note that these are the only two nomsomorphlc table structures (up to the renaming of keys and table locations) for this case. Thus, a sorted table is not optimal for n = 2, m = 3. We now show, however, that a sorted table is optimal as soon as n = 2, m -- 4 (hence for all n -- 2, m > 4). Any table structure for n = 2, m = 4 can be uniquely represented as a directed graph on four labeled vertices { 1, 2, 3, 4}. We draw an edge i ~ j if the pair {i, j} is stored as [i-~. For example, the graph in Figure 2 represents a table structure with { 1, 4) stored as ~ and (2, 4) as ~--~. For any three vertices in the graph, the edges between them may or may not form a directed cycle. It is not hard to show that for any such graph on four vertices, there exist three vertices among which the edges are acyclic. In Figure 2, { 1, 3, 4} is such a set of three vertices. If we consider the set of keys corresponding to these verhces as a subspace with m = 3, we find that we are storing these keys as a "permuted" sorted table, that is, one that differs from the sorted table only in a new ordering 3 < 1 < 4 of the elements (Figure 3). But this means that any searching strategy for this table structure must make two probes m the worst case. This proves that f(2, 4) _> 2, and hence the sorted table is optimal for n = 2, m >_ 4.

3 Should Tables Be Sorted? /1",,, 3 131,1 FIG 2 A typical table FIG 3 The "permuted'" structure for n = 2, m = 4 sorted table corresponding to {1, 3, 4) from Figure 2 The preceding statement generalizes to any fixed n; that is, the sorted table scheme Is optimal for any fixed n, provided that the key space Is large enough. THEOREM 1. For every n there exists an N(n) such that f(n, m) = [lg(n + l)]for all rn >_ N(n). PROOF. argument. We need the following lemma, which can be proved by an adversary LEMMA 1. If a table structure stores the keys of a table m sorted order (or according to some fixed permutatwn), then [lg(n + 1)] probes are needed in the worst case by any search strategy provided that rn >_ 2n - 1 and n >_ 2. PROOF. We will construct an adversary strategy to show that [lg(n + 1)] probes are required to search for the key value K = n of the space {1, 2... m}. The construction ~s by induction on n. For n -- 2 and m _ 3 it is easy to see that two probes are required. Let no > 2. Assume the induction hypothesis to be true for all n < no; we will prove it for n = no, m - 2no - 1, and K = no. By symmetry, assume that the first probe position p satisfies p _< [no/2]. The adversary answers T(p) = p. Then the key no may be in any position i, where [no/2] + 1 i no. In fact, T([no/2] + 1) through T(no) is a sorted table of size n' = [no/2j which may contain any subset of {[no/2] + 1, [no/2] m}, and hence, in particular, any subset of the key space M' = {[no/2] + 1, [no/2] m - [no/2]}. The size m' of M' satisfies and the desired key no has relative value K' = no - [n0/2] = n' in the key space M'. By the induction hypothesis, [lg(n' + 1)] more probes will be reqmred. Hence the total number of probes is at least 1 + [lg(n' + 1)] = 1 + [lg([n0/2j + 1)] _> [lg(n0 + 1)]. This completes the induction step. [] To prove Theorem 1, the idea is to show that If m IS large enough, then for any table structure Jthere is a set So of 2n - I keys with the following property: Given any n-key subset A C So, the table structure always arranges the keys of A according to some fixed permutation. Lemma 1 will then imply the [lg(n + 1)] bound. To this end, let us partition d, the family of n-key subsets of M, into n! parts as follows. For each A = {J1 < j2 <.-- < jn} E d, let Ta be the table formed under ~-. We assign A to the group o(6, tz... in) if Ta(il) = J1, Ta(iz) = J2... TaOn) = jn. The collection {o(6, t2... in)[(ll, t2... in) is a permutation of {1, 2... n}} forms a partmon of d.

4 618 ANDREW CHI-CHIH YAO CLAIM. If m is sufficiently large, then there exists a set of 2n - 1 keys So _C (1, 2... m } such that for all n-key subsets A _C So we have A ~ o(il, i2,.., in), where (il, i2... in) is a fixed permutation. By our earlier discussion this would imply Theorem 1. It remains to prove the claim. We make use of the following famous combinatorial theorem (see, e.g., [3]). RAMSEY'S THEOREM. For any k, r, t, there exists a finite number R(k, r, t) such that the following is true. Let S = (1, 2... m) with m _> R(k, r, t). If we divide the family of all r-element subsets of S into t parts, then at least one part contains all the r- element subsets of some k elements of S. Our claim follows from Ramsey's Theorem by choosing r = n, t = n! and k = 2n - 1. This proves Theorem 1 with N(n) = R(2n - 1, n, n!). [] Generalization. As we mentioned at the beginning of this section, Theorem 1 holds under more general conditions. In the general setting a table may contain "pointers" and duplicated keys. Formally, we have a universe M of m keys, a set P ofp special symbols (pointers), and an array T containing q cells. Let S..C M be any subset of n keys. We store S in T, where each cell may contain any element in the set S O P. Each key in S may appear several times, or may not appear at all. A rule for determining the above assignment is a table structure ~. Defining search strategies ~as before, we measure the cost c (J, ~) by the number of probes needed to answer the membership query in the worst case. The complexityf(n, m, p, q) is the minimum cost achievable by such a pair. THEOREM 1'. For any n, p, q, there exists an N(n, p, q) such that f(n, m, p, q) = [lg(n + 1)] for all m _> N(n, p, q). PROOF. As the proof is very similar to that of Theorem 1, we shall only sketch it. Clearly we need only prove thatf(n, m, p, q) _> [lg(n + 1)] for all large m. Let 3-be any table structure. To each n-key subset S we assign a q-tuple (il, i iq) with 1 _< it _< n + p, where iz = k if T[I] contains the kth smallest key in S and h = n + j if T[I] contains thejth pointer. This partitions the family of all n-key subsets into (n + p)q classes. If m _> R(2n - 1, n, (n + p)q), then by Ramsey's theorem there exists a set So of 2n - 1 keys all of whose n-key subsets are in the same class. By definition, all tables for n-key subsets S C So contain identical pointers in each location, and hence tables are distinguished only by the keys stored in the tables. Now, in these tables the set of locations containing a given key depends only on the relative ranking of the key in the n-key subset. Therefore, from the viewpoint of search strategies, these are sorted tables (with possible missing keys). By Lemma 1, it takes [lg(n + 1)] probes in the worst case. As ~-is arbitrary, this proves the theorem. [] We may further allow the set S to have nonunique representations as a table (as is the case of hash tables and search trees), since this obviously will not ~mprove the worst case cost. Thus the present model allows for the use of linked lists, search trees, all common hashing techniques, etc. 3. When Is One Probe Sufficient? The numbers N(n) in Theorem 1 are extremely large even for moderate n. Thus the result is not too useful in practical terms. It is of interest to understandf(n, m) for smaller m. We therefore ask the following equivalent question: Given n, k, what is the maximum m such thatf(n, m) = k? Call this number g(n, k). Hence, if and only

5 Should Tables Be Sorted? 619 tenants room FIG The assooatlon between tenants and rooms m the proof of Theorem 2 if there are more than g(n, k) possible keys, then we have to use more than k probes in the worst case. The determination ofg(n, k) ts difficult, but we can determine it in one special case. THEOREM 2 = [ 3 /f n = 2, g(n, 1) 2n-2 /f n>2. L PROOF. We shall give a proof for the lower bound to g(n, 1) by exhibiting a l- probe table structure for the asserted number of keys. The other part of the proof, that is, that no table structure can achieve a l-probe search for a larger key space, involves a lengthy case analysis and is left to Appendix A. For the case n = 2, m = 3, the "cyclic" table discussed earlier has an obvious l- probe search strategy. Now let n > 2 and m = 2n - 2; we describe a table structure allowing a l-probe search strategy. Consider the situation as m people sharing an apartment building with n rooms. We need a method so that no matter which n people appear at the same time, we can assign them in such a way that it is possible to determine if person j is present by looking up the occupant of one particular room (dependent on j). We use K~ to stand for the personj (1 _<j _~ m). Let us call Kj and K,+~ the tenants of room j, for 1 _< j <_ n - 2; Kj is the lower tenant and Kn+j the upper tenant. For room n - 1, K,~-i is a lower tenant, and for room n, Kn is a lower tenant. There are no upper tenants for these two special rooms. (See Figure 4.) When a group of n people shows up, we make the assignment by the following steps. (i) If room j (1 ~ j _< n - 2) has only one tenant present, assign that tenant to the room. (ii) Ifa roomj (1 <_j _< n - 2) has both tenants present, let the upper tenant go to a room which has no tenants present. (iii) Those people left unassigned are either tenants whose upper tenants are also present, or are keys K,-1, K,. We assign them so that they do not occupy the rooms of which they are tenants (e.g., a cyclic shift will do). The last step can always be accomphshed, for we can argue that if there is at least one person left in (iii), then there are at least two. Indeed, either (a) assuming neither Kn-~ nor K, is present, then at least two rooms j (1 _<j _< n - 2) have both tenants present; (b) assuming exactly one of K,-1, K, is present, then there must be another j (1 ~_j _< n - 2) with both tenants present; or (c) both K,-1 and Kn are present. For example, assume in Figure 5 that the group (1, 2, 3, 6, 7, 9, 10, 12) shows up. Steps (i)-(iii) are illustrated. To answer if Kj is in the table, we look at the room of which it is a tenant. (a) If Kj is there, then it is m the table. (b) If an upper tenant of some other room is there, then Kj is not in the table. (c) If a lower tenant of some other room is there, then Kj is in the table.

6 620 ANDREW CHI-CHIH YAO step (i) step (,,) step (m) FIG 5 An illustration of steps (O-On) in the assignment FIG 6 Fadure of the i-probe scheme with 2n - 1 keys It ts straightforward to verify the correctness of the answers. This proves g(n, 1) _> 2n - 2 for n > 2. It remains to prove the upper bounds for g(n, 1). We have shown that g(2, 1) < 4 in Section 2. The proof ofg(n, 1) <_ 2n - 2 for n _> 3 is left to Appendix A. [] Note that the above scheme only allows one to determine in one probe whether an element is in the table, but not the location of the element (when it is in). It would be interesting to study schemes that can determine the stored locations of the elements and to determine how large a key space can be accommodated under this stronger requirement. Remark. It Is somewhat surprising that the l-probe schemes used in the above proof are optimal, as they look quite arbitrary. In particular, why do we need two special rooms n - 1 and n? Figure 6 shows that the scheme fails if we have only one special room (and 2n - 1 keys). The arrival of keys 1, 2... n - 1, n + 1 will make the accommodation impossible. 4. Searching in Two Probes How strong is Theorem 1'? It appears to be a robust result, considering its generality. However, the following surprising result demonstrates that it depends heavily on the fact that keys outside of the set S may not be present m the table. THEOREM 3. There exists a number N'(n) such that if m _> N'(n), then by adding one extra cell in a sorted table, the search can always be accomplished tn two probes. (The content in the extra cell is allowed to be any integer between l and m.)

7 Should Tables Be Sorted? f sorted table.a. N 621 cell n FIG 7 A 2-probe table PROOF. We define a concept called "k-separating systems." Let M = (1, 2... m) and n > 0 an integer. An n-separator F = (A1, A2... An) is an ordered n-tuple of subsets A, _C M which are mutually disjoint. An n-separating system for M is a famdy of n-separators such that for any n elements xl < x2 < < x, of M, there exists (not necessarily unique) a member F = (A1, A2... An) E ~with x, E As for i = l, 2... n. Let us use ~b(xl, x2... xn) to denote this F. For y E U]=i Aj, use J(F, y) to denote the j with y E A~. We now show how to design a 2-probe structure with the help of an n-separating system W for M. Let W= {F1, F2... Fl}. For each n-tuple a = (xl < Xz <... < Xn) drawn from M, let F, ta) = ~b(xl, xz... Xn). For the moment assume that ] ~[ = l _< m. We organize the table as shown in Figure 7. To test lfa numbery E M is in the table, one first probes at cell 0 to find i(a), then makes a second probe at position J(F,(a), y). The numbery is in the table if and only if it is in this location. Reason. Let F~(a) = (A1, A2... A,); if y is in the table, then y E Aj with j = J(F,(~), y), and hence must be in thejth cell. It remains to examine the condition that l < m. We need the following combinatorial lemma. LEMMA 2. There exists an n-separating system ~for S with [~[ _< 4 n2. (Ig m) n-1. PROOF. See Appendix B. [] It follows from the lemma that if4n2.(lg m) 0-~ _< m, then the 2-probe scheme works. The condmon is satisfied if m _> N'(n) = 216"2. This proves Theorem 3. [] Bob Tarjan [private communication] has improved the bound N'(n) in Theorem 3 to exp(cn log n) by a somewhat different construction. In the proof of Theorem 3, the table structure used has a "directory" at cell 0. To retrieve a key y, one consults the directory to probe a cell which would contain j if and only ify is in the table. (Tarjan's construction also follows this pattern.) It is of interest to find tight bounds on m, n for such table structures (call them canomcal 2- probe structures) to exist. Define a primmve n-separating system ~ for M = (1, 2... m} to be a family of n-separators such that for any n distinct elements Xl, x2... x, of M, there exists a member F = (At, A2... A~) ~ ~with each As containing exactly one xj. Let b(m, n) be the minimum size of such a primitive n- separating system. It can be shown that m _> b(m, n) is a necessary and sufficient condition for a canonical 2-probe structure to exist. Ron Graham [private communication] has shown that asymptotically b(m, n) _< ~n enlog m by a nonconstructwe argument which implies the existence of a canonical 2-probe structure whenever m _> exp(cn) for some constant c > Conclustons We have discussed the complexity of the "membership" retrieval problem. The main conclusions are, roughly, that when the word size is large, sorted tables are optimal

8 622 ANDREW CHI-CHIH YAO structures if only the addressing power of a random-access machine can be used, but far from optimal once arbitrary encoding of the information is allowed in the table. These results are mainly of theoretical interest, although Theorem 3 suggests that there may be fast retrieval schemes in more practical situations. The Ramsey type technique used in the proof of Theorem 1 may have wider applications. Ron Rivest [private communication] has used it to prove a conjecture concerning [13]. Below we mention some subjects for future research. We have proved the optimality of sorted tables in a rather general framework (Theorem 1'). It would be nice if the threshold value N(n) could be substantially lowered. Also, the exact determination of quantities such as g(n, 2) poses challenging mathematical questions. When arbitrary encoding was allowed, we obtained a rather curious result (Theorem 3). In either of the extreme cases m ~ n and m _> 216n2, one needs at most two probes to decide if an item is in a table. In the former case the addressing power, and in the latter case the encoding power, contribute to fast retrieval. It would be interesting to study the problem for intermediate values of m. Tarjan and Yao [19] have shown that when m grows at most polynomially in n, one can retrieve in O(1) probes with a O(n)-cell table. The question is still open for other ranges of m, say, m = 2 "~. Another direction of research is to study the effect of restricting the decoding procedures. A main theme of this paper has been to discuss the membership problem in a word-length-independent framework (by letting m ~ oo). We list some open problems of prime importance in this framework, which are indirectly related to the membership problem. (1) It is easy to construct similar models for more complex data manipulation problems such as executing a sequence of "INSERT," "DELETE," "MIN." We conjecture that, unlike the membership problem, nonconstant lower bounds exist even if arbitrary encoding is allowed. (2) The Post Office Problem [4, 14]. Consider n points vl, v2... vn on an m m lattice (with m --> oo). Can we encode them m cn cells so that, given any point on the lattice, we can find the nearest v, in O(1) probes? In fact, this problem is unresolved even in the one-dimensional case. (3) Sorting Networks. In the usual Boolean networks for sorting n inputs in {0, 1), it is known [1 l] that one need only use O(n) gates A, V, 7. If we consider gates that are functions from M M to M, can we build a sorting network for n inputs from M with O (n) gates as m --~ oo? In general, the study of such networks for function computation would be interesting. See Vilfan [21] for some discussions on the formula size problems. Appendix A. Proof of Optimality in Theorem 2 In this appendix we complete the proof of Theorem 2 by showing that g(n, 1) _< 2n - 2 for n _> 3. For convenience, the inductive proof is organized in the following way. We first prove that for any n _> 3 and m = 2n - 1, a table structure allowing a 1-probe search induces a 1-probe table structure for n' = n - 1 and m' -- 2n' - 1. Then we demonstrate that for n = 3 and m = 2n - 1 = 5, there cannot be any l- probe table structure. This immediately implies g(n, 1) < 2n - 1 for all n _> 3, completing the proof. Suppose there is a l-probe table structure J- for n, m -- 2n - 1, where n _> 3. For 1 _<j _< 2n - 1, let lj be the location to examine when keyj is to be retrieved. Clearly, some location will be lj for at least two distinct j. Without loss of generality, assume

11 Should Tables Be Sorted? 625 test for test for test for keys 1,2 key5 key 4 test for test for test for keys 1,2 key5 key FIG 10 More knowledge about FIG 11 Adding (2, 5, 1) and the table structure (2, 1, 4) to the structure PROOF. If (a) X (a)' or (b) x (b)', then one cannot test in one probe whether key 4 is in the table (recall that/4 # l). If (a) (b)', again one cannot test in one probe whether key 4 is in the table -- if/4 = 2, then the tables (1, 3, 4) and (5, 3, 2) cannot be distinguished, and if/4 = 3, then (l, 5, 3) and (4, 2, 3) cannot be distinguished. Therefore, the table structure must contain the tables shown in Figure 9. [] How is the (3, 4, 5} arranged as a table? One cannot put key 4 or 5 into cell l since that would imply the presence of key 2. Also, the arrangement as (3, 4, 5) would make it impossible to test for key 3 (since there is a (l, 4, 5)). Thus it has to be arranged as (3, 5, 4). We now assert that/.5 = 2 and/4 = 3. Testing for key 5 at cell 3 cannot distinguish (l, 3, 4) and (3, 5, 4), and testing for key 4 at cell 2 cannot distinguish (l, 5, 3) and (3, 5, 4). Our knowledge about the l-probe table structure thus far is summarized in Figure 10. To fill in the slots for (1, 2, 4} and (l, 2, 5}, we note that key 2 has to be put into cell l since both keys l and 2 are here. The only posslbdity for (1, 2, 5} is (2, 5, 1); the alternative (2, l, 5) would jeopardize the test for key 4, since (1, 4, 5) is already there. This also means that T[3] = l implies the absence of key 4. It follows that (l, 2, 4} has to be arranged as (2, l, 4). The known part of the table structure is shown in Figure I I. However, there is now no way to test for key 3! If we probe at cell 2, the two tables (3, 5, 4) and (2, 5, l) cannot be distinguished; if we probe at cell 3, the tables (l, 3, 4) and (2, l, 4) wdl look the same. This contradicts the defimtlon of a table structure allowing a l-probe search strategy. We have thus proved that no l-probe table structure can exist for n = 3, m = 5. This completes the proof for g(n, l) < 2n - l (n _> 3) and hence Theorem 2. [] Appendix B. Proof of Lemma 2 Let m _> k _> 2 and S -- (1, 2... m}. We shall construct a k-separating system Y for S such that [~1-4k2(lgm) k-l. We agree that the O-separating system is, and the l-separating system for any T is {T}. The system,~ will be recurslvely constructed m the lexicographic order of (k, m). Divide S consecutively into k almost equal blocks Sa, $2... Sk with IS, ] = m, -- [(m + i - l)/kl. We define ~ as the umon of the following famdles of k-

12 626 ANDREW CHI-CHIH YAO separators, to be described in a moment: d and ~(nl, n2... nd, where 0 _< n, < k are integers satisfying ~, n, = k. Let F, -- (A,x, A,2..., A,D be a k-separator for the set S, (1 _< i _< k). The direct sum Fi ~ Fz Fk is the k-separator (Aa, A2... AD, where Aj -- I.,I,A~j. Let t > 0 and, for each 1 _< i_< k, ~ -- {F,~, F,2... F,t} be a family of k-separators for S,. Define the dtrect sum ~2 ~k to be the family of k-separators for S,,.~ -- (F1, F2... Ft}, where Fj = F2j for 1 _< j _< t. We now construct alas follows. Let ~ (1 _< t _< k) be a k-separating system for S,, constructed recursively. 2 For each j, add arbitrary k-separators into ~ so that the resulting family ~; has t = max, [~ I elements. We now define d = ~g. For each xl < x2 < < xk there is clearly a k-separator F -- (A1, A2... AD ~ d that "separates" the x's (i.e., such that xj ~ Aj for all j) if all xj are in the same block S,. For each (nl, n2... nk) that satisfies 0 _< n, < k and ~,n, -- k, the family of separators ~(nl, n2... nk) is constructed as follows. The family ~(m, n2... nd is empty if there is some i such that n, > m,. Otherwise, for each 1 _< i _< k let ~" be an n,-separating system for S,, recursively constructed. Denote by ~(nx, n2,..., nd the family of all k-separators of the form F = (A~, A~2... Ai~, A2~... A2,~... Akn~), where each (A~, A,2... A,n,) ~ ~". For any x~ < x2 < < Xk in S such that exactly n, of the x's are in S, for each i, there is clearly some k-separator in ~(m, n2..., nd that separates the x's. Let ~ = ~/O (Un,~(nl, n2... nd). Then ~ is a k-separating system for S, as implied by the properties of ~ and ~ stated above. Let f~(n) denote the size of constructed this way. Then by definition, fi(m) = max,fi + ~ H fn,(m,), (l:])} O~n~<k t~l ~n,=k for m_>k>_2. (B1) We adopted in (B1) the convention that fo(mo = 1 andfn,(m,) = 0 if n, > m,. FACT B1. For each k _> 2, f~(m) is a nondecreasingfunction of re. PROOF. Using (BI), one can prove it by induction on (k, m), lexicographically. [] We shall now prove, by induction on k, the following formula: 3 f~(m) _< 4kZ(lg m) k-~ for m _> k _> 1. (B2) The formula is obviously true for k = 1. Let k > l; we shall prove (B2) assuming that it is true for all smaller values of k. First we prove the following fact. FACT B2. For m = k t, where t _> l is an integer, we have fk(m) --< 4k~(½ lg m) ~-~. PROOF. Using (B1), Fact Bl, and the induction hypothesis, we have fk(m)<--fk(~) +~o_<n, <k fo~ ~a, 4X'n~(lg m)x'~n'-~)" (B3) ~n,=k In (B3), the summations ~' are over those i with n, # O. The second term in (B3) is at most (2kk_-ll) 4t~-~)2+l(lg m)k-2 < ~ 1.4~2_k+2(lg m)k_2. 2 We agree that.~, = ~5 if k > I S, I. Also note that when k > I S, l, any k-separator (A~, A2,, Mk) for S, must have some A~ = ~5 a We mterpret 0 to be 1

13 ShouM Tables Be Sorted? 627 Thus (B3) implies _<~ +~.2.4 k~ lgm l < - (lo~m) 4 k~ lg m -2 m) k-1 _< 4k2 (~ lg [] For general m, let k t-i _< m < k t where t >_ 2. By Facts B1 and B2, fk(m) ~. 4 k2 lg k t < 4k~(lg m) k-1. This completes the inductive proof for (B2) and hence Lemma 2. [] A Bibliographic Note. The complexity of the membership problem was first raised in Minsky and Papert [10, pp ], where it was called the exact match problem. The model was formulated on a bitwise-access machine, with the complexity defined as the average number of bits needed to be examined for a random table. This model, especially the n = 1 case, was further examined by Elias and Flower [61, but the problem has not been solved completely even for this special case. Wordwise-access models were used in several recent papers. Sprrugnoli's work [16] dealt with efficient hash functions and is closely related to the materials in Section 4 of the present paper. Taljan [171 showed that tables of size O(n) and retrieval time O(log*n) can be achieved if m is at most polynomial in n; the retrieval time was improved to O(1) by Ta~an and Yao [19. Also see Bentley et. al [2[, Gonnet [7], and Munro and Suwanda [121 for other recent studies on related problems. ACKNOWLEDGMENT. I wish to thank Bob Tarjan for many helpful comments, which led me to include Theorem l' in the paper. REFERENCES 1 AHO, A V., HOPCROFT, J.E, AND ULLMAN, J D The Destgn and Analysis of Computer Algornhms Addison-Wesley, Reading, Mass., BENTLEY, J, DETIG, D, GUIBAS, L., AND SAXE, J. An opttmal data structure for mmnnal-storage dynamic member searching Unpublished manuscript. 3 BERGE, C Graphs and Hypergraphs North-Holland, Amsterdam, DOBKIN, D., AND LIPTON, R J Multidimensional search problems SIAM J Comput 5 (1976), ELIAS, P Efficient storage and retrieval by content and address of static files J. A CM 21, 2 (April 1974), ELIAS, P., AND FLOWER, R A The complexity of some smaple retrieval problems J A CM 22, 3 (July 1975), GONNET, G H Average lower bounds for open-addressing hash coding. Proc Conf on Theoretical Computer Science, Waterloo, Ontario, Canada, August 1977, pp KNUTH, DE TheArtofComputerProgrammmg, Vol 1. FundamentalAlgomhms Addision-Wesley, Reading, Mass, 1968

CHAPTER II THE LIMIT OF A SEQUENCE OF NUMBERS DEFINITION OF THE NUMBER e. This chapter contains the beginnings of the most important, and probably the most subtle, notion in mathematical analysis, i.e.,

On an anti-ramsey type result Noga Alon, Hanno Lefmann and Vojtĕch Rödl Abstract We consider anti-ramsey type results. For a given coloring of the k-element subsets of an n-element set X, where two k-element

Large induced subgraphs with all degrees odd A.D. Scott Department of Pure Mathematics and Mathematical Statistics, University of Cambridge, England Abstract: We prove that every connected graph of order

An example of a computable absolutely normal number Verónica Becher Santiago Figueira Abstract The first example of an absolutely normal number was given by Sierpinski in 96, twenty years before the concept

Universal hashing No matter how we choose our hash function, it is always possible to devise a set of keys that will hash to the same slot, making the hash scheme perform poorly. To circumvent this, we

73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

Mean Ramsey-Turán numbers Raphael Yuster Department of Mathematics University of Haifa at Oranim Tivon 36006, Israel Abstract A ρ-mean coloring of a graph is a coloring of the edges such that the average

Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

How Not to Win a Million Dollars: A Counterexample to a Conjecture of L. Breiman Thomas P. Hayes arxiv:1112.0829v1 [math.pr] 5 Dec 2011 Abstract Consider a gambling game in which we are allowed to repeatedly

136 TER 4. INDUCTION, GRHS ND TREES 4.3 Graphs In this chapter we introduce a fundamental structural idea of discrete mathematics, that of a graph. Many situations in the applications of discrete mathematics

MA651 Topology. Lecture 6. Separation Axioms. This text is based on the following books: Fundamental concepts of topology by Peter O Neil Elements of Mathematics: General Topology by Nicolas Bourbaki Counterexamples

Two classes of ternary codes and their weight distributions Cunsheng Ding, Torleiv Kløve, and Francesco Sica Abstract In this paper we describe two classes of ternary codes, determine their minimum weight

SIAM J. COMPUT. Vol. 4, No. 1, March 1975 FINDING ALL THE ELEMENTARY CIRCUITS OF A DIRECTED GRAPH* DONALD B. JOHNSON Abstract. An algorithm is presented which finds all the elementary circuits-of a directed

Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

AN ALGORITHM FOR DETERMINING WHETHER A GIVEN BINARY MATROID IS GRAPHIC W. T. TUTTE. Introduction. In a recent series of papers [l-4] on graphs and matroids I used definitions equivalent to the following.

The Union-Find Problem Kruskal s algorithm for finding an MST presented us with a problem in data-structure design. As we looked at each edge, cheapest first, we had to determine whether its two endpoints

Chapter 3 Linear Codes In order to define codes that we can encode and decode efficiently, we add more structure to the codespace. We shall be mainly interested in linear codes. A linear code of length

Odd induced subgraphs in graphs of maximum degree three David M. Berman, Hong Wang, and Larry Wargo Department of Mathematics University of New Orleans New Orleans, Louisiana, USA 70148 Abstract A long-standing

Is Sometime Ever Better Than Alway? DAVID GRIES Cornell University The "intermittent assertion" method for proving programs correct is explained and compared with the conventional method. Simple conventional

Collinear Points in Permutations Joshua N. Cooper Courant Institute of Mathematics New York University, New York, NY József Solymosi Department of Mathematics University of British Columbia, Vancouver,

CMSC 858T: Randomized Algorithms Spring 2003 Handout 8: The Local Lemma Please Note: The references at the end are given for extra reading if you are interested in exploring these ideas further. You are

TAKE-AWAY GAMES ALLEN J. SCHWENK California Institute of Technology, Pasadena, California L INTRODUCTION Several games of Tf take-away?f have become popular. The purpose of this paper is to determine the

On the k-path cover problem for cacti Zemin Jin and Xueliang Li Center for Combinatorics and LPMC Nankai University Tianjin 300071, P.R. China zeminjin@eyou.com, x.li@eyou.com Abstract In this paper we

Analysis of Algorithms I: Binary Search Trees Xi Chen Columbia University Hash table: A data structure that maintains a subset of keys from a universe set U = {0, 1,..., p 1} and supports all three dictionary

Chapter 5 The Ideal Class Group We will use Minkowski theory, which belongs to the general area of geometry of numbers, to gain insight into the ideal class group of a number field. We have already mentioned

Volume 2, No. 3, March 2011 Journal of Global Research in Computer Science RESEARCH PAPER Available Online at www.jgrcs.info IMPROVING PERFORMANCE OF RANDOMIZED SIGNATURE SORT USING HASHING AND BITWISE

Prime Numbers and Irreducible Polynomials M. Ram Murty The similarity between prime numbers and irreducible polynomials has been a dominant theme in the development of number theory and algebraic geometry.

PRIME FACTORS OF CONSECUTIVE INTEGERS MARK BAUER AND MICHAEL A. BENNETT Abstract. This note contains a new algorithm for computing a function f(k) introduced by Erdős to measure the minimal gap size in

9. Summation Notation 66 9. Summation Notation In the previous section, we introduced sequences and now we shall present notation and theorems concerning the sum of terms of a sequence. We begin with a

Introduction to computer science Michael A. Nielsen University of Queensland Goals: 1. Introduce the notion of the computational complexity of a problem, and define the major computational complexity classes.

Open Research Online The Open University s repository of research publications and other research outputs The degree-diameter problem for circulant graphs of degree 8 and 9 Journal Article How to cite:

Mathematical Induction (Handout March 8, 01) The Principle of Mathematical Induction provides a means to prove infinitely many statements all at once The principle is logical rather than strictly mathematical,

CHAPTER 7 GENERAL PROOF SYSTEMS 1 Introduction Proof systems are built to prove statements. They can be thought as an inference machine with special statements, called provable statements, or sometimes

Duplicate Record Elimination in Large Data Files DINA BITTON and DAVID J. DeWlTT University of Wisconsin-Madison The issue of duplicate elimination for large data files in which many occurrences of the

CONSTRUCTION OF THE FINITE FIELDS Z p S. R. DOTY Elementary Number Theory We begin with a bit of elementary number theory, which is concerned solely with questions about the set of integers Z = {0, ±1,

The degree, size and chromatic index of a uniform hypergraph Noga Alon Jeong Han Kim Abstract Let H be a k-uniform hypergraph in which no two edges share more than t common vertices, and let D denote the

INCIDENCE-BETWEENNESS GEOMETRY MATH 410, CSUSM. SPRING 2008. PROFESSOR AITKEN This document covers the geometry that can be developed with just the axioms related to incidence and betweenness. The full

CHAPTER 5 Number Theory 1. Integers and Division 1.1. Divisibility. Definition 1.1.1. Given two integers a and b we say a divides b if there is an integer c such that b = ac. If a divides b, we write a

CSE 291: Geometric algorithms Spring 2013 Lecture 4 Online and streaming algorithms for clustering 4.1 On-line k-clustering To the extent that clustering takes place in the brain, it happens in an on-line

MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive