{'fraction_non_alphanumeric': 0.04694237099541008, 'fraction_numerical': 0.009852102554592238, 'mean_word_length': 3.7974866548042705, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 9, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Converting online algorithms to local computation algorithms

We propose a general method for converting online algorithms to local computation algorithms by selecting a random permutation of the input, and simulating running the online algorithm. We bound the number of steps of the algorithm using a query tree, which models the dependencies between queries. We improve previous analyses of query trees on graphs of bounded degree, and extend the analysis to the cases where the degrees are distributed binomially, and to a special case of bipartite graphs. Using this method, we give a local computation algorithm for maximal matching in graphs of bounded degree, which runs in time and space O(log^3 n). We also show how to convert a large family of load balancing algorithms (related to balls and bins problems) to local computation algorithms. This gives several local load balancing algorithms which achieve the same approximation ratios as the online algorithms, but run in O(log n) time and space. Finally, we modify existing local computation algorithms for hypergraph 2-coloring and k-CNF and use our improved analysis to obtain better time and space bounds, of O(log^4 n), removing the dependency on the maximal degree of the graph from the exponent.


Background
The classical computation model has a single processor which has access to a given input, and using an internal memory, computes the output. This is essentially the von Newmann architecture, which has been the driving force since the early days of computation. The class of polynomial time algorithms is widely accepted as the definition of efficiently computable problems. Over the years many interesting variations of this basic model have been studied, focusing on different issues.
Online algorithms (see, e.g., [7]) introduce limitations in the time domain. An online algorithm needs to select actions based only on the history it observed, without access to future inputs that might influence its performance. Sublinear algorithms (e.g. [11,15]) limit the space domain, by limiting the ability of an algorithm to observe the entire input, and still strive to derive global properties of it.
Local computation algorithms (LCAs) [16] are a variant of sublinear algorithms. The LCA model considers a computation problem which might have multiple admissible solutions, each consisting of multiple bits. The LCA can return queries regarding parts of the output, in a consistent way, and in poly-logarithmic time. For example, the input for an LCA for a job scheduling problem consists of the description of n jobs and m machines. The admissible solutions might be the allocations of jobs to machines such that the makespan is at most twice the optimal makespan. On any query of a job, the LCA answers quickly the job's machine. The correctness property of the LCA guarantees that different query replies will be consistent with some admissible solution.

Our results
Following [2], we use an abstract tree structure -query trees to bound the number of queries performed by certain algorithms. We use these bounds to improve the upper bound the time and space requirements of several algorithms introduced in [2]. We also give a generic method of transforming online algorithms to LCAs, and apply it to obtain LCAs to maximal matching and several load balancing problems.

Bounds on query trees
Suppose that we have an online algorithm where the reply to a query depends on the replies to a small number of previous queries. The reply to each of those previous queries depends on the replies to a small number of other queries and so on. These dependencies can be used to model certain problems using query trees -trees which model the dependency of the replies to a given query on the replies to other queries.
Bounding the size of a query tree is central to the analyses of our algorithms. We show that the size of the query tree is O(log n) w.h.p., where n is the number of vertices. d, the degree bound of the dependency graph, appears in the constant. 4 This answers in the affirmative the conjecture of [2]. Previously, Alon et al. [2] show that the expected size of the query tree is constant, and O(log d+1 n) w.h.p. 5 Our improvement is significant in removing the dependence on d from the exponent of the logarithm. We also show that when the degrees of the graph are distributed binomially, we can achieve the same bound on the size of the query tree. In addition, we show a trivial lower bound of Ω(log n/ log log n).
We use these results on query trees to obtain LCAs for several online problemsmaximal matching in graphs of bounded degree and several load balancing problems. We also use the results to improve the previous algorithms for hypergraph 2-coloring and k-CNF.

Hypergraph 2-coloring
We modify the algorithm of [2] for an LCA for hypergraph 2-coloring, and coupled with our improved analysis of query tree size, obtain an LCA which runs in time and space O(log 4 n), improving the previous result, an LCA which runs O(log d+1 n) time and space.

k-CNF
Building on the similarity between hypergraph 2-coloring and k-CNF, we apply our results on hypergraph 2-coloring to give an an LCA for k-CNF which runs in time and space O(log 4 n).
We use the query tree to transform online algorithms to LCAs. We simulate online algorithms as follows: first a random permutation of the items is generated on the fly. Then, for each query, we simulate the online algorithm on a stream of input items arriving according to the order of the random permutation. Fortunately, because of the nature of our graphs (the fact that the degree is bounded or distributed binomially), we show that in expectation, we will only need to query a constant number of nodes, and only O(log n) nodes w.h.p. We now state our results:

Maximal matching
We simulate the greedy online algorithm for maximal matching, to derive an LCA for maximal matching which runs in time and space O(log 3 n).

Load Balancing
We give several LCAs to load balancing problems which run in O(log n) time and space. Our techniques include extending the analysis of the query tree size to the case where the degrees are selected from a binomial distribution with expectation d, and further extending it to bipartite graphs which exhibit the characteristics of many balls and bins problems, specifically ones where each ball chooses d bins at random. We show how to convert a large class of the "power of d choices" online algorithms (see, e.g., [3,6,18]) to efficient LCAs.

Related work
Nguyen and Onak [13] focus on transforming classical approximation algorithms into constant-time algorithms that approximate the size of the optimal solution of problems such as vertex cover and maximum matching. They generate a random number r ∈ [0, 1], called the rank, for each node. These ranks are used to bound the query tree size.
Rubinfeld et al. [16] show how to construct polylogarithmic time local computation algorithms to maximal independent set computations, scheduling radio network broadcasts, hypergraph coloring and satisfying k-SAT formulas. Their proof technique uses Beck's analysis in his algorithmic approach to the Lovász Local Lemma [4], and a reduction from distributed algorithms. Alon et al. [2], building on the technique of [13], show how to extend several of the algorithms of [16] to perform in polylogarithmic space as well as time. They further observe that we do not actually need to assign each query a rank, we only need a random permutation of the queries. Furthermore, assuming the query tree is bounded by some k, the query to any node depends on at most k queries to other nodes, and so a k-wise independent random ordering suffices. They show how to construct a 1/n 2 -almost k-wise independent random ordering 6 from a seed of length O(k log 2 n).
Recent developments in sublinear time algorithms for sparse graph and combinatorial optimization problems have led to new constant time algorithms for approximating the size of a minimum vertex cover, maximal matching, maximum matching, minimum dominating set, and other problems (cf. [15,11,13,20]), by randomly querying a constant number of vertices. A major difference between these algorithms and LCAs is that LCAs require that w.h.p., the output will be correct on any input, while optimization problems usually require a correct output only on most inputs. More importantly, LCAs reuire a consistent output for each query, rather than only approximating a given global property.
There is a vast literature on the topic of balls and bins and the power of d choices. (e.g. [3,6,9,18]). For a survey on the power of d choices, we refer the reader to [12].

Organization of our paper
The rest of the paper is organized as follows: Some preliminaries and notations that we use throughout the paper appear in Section 2. In Section 3 we prove the upper bound of O(log n) on the size of the query tree in the case of bounded and binomially distributed degrees. In section 4, we use this analysis to give improved algorithms for hypergraph 2-coloring and k-CNF. In Section 5 we give an LCA for finding a maximal matching in graphs of bounded degree. Section 6 expands our query tree result to a special case of bipartite graphs; we use this bound for bipartite graph to convert online algorithms for balls and bins into LCAs for the same problems. The appendices provide in-depth discussions of the hypergraph 2-coloring and analogous k-CNF LCAs, and a lower bound to the query tree size.

Preliminaries
Let G = (V, E) be an undirected graph. We denote by N G (v) = {u ∈ V (G) : (u, v) ∈ E(G)} the neighbors of vertex v, and by deg G (v) we denote the degree of v. When it is clear from the context, we omit the G in the subscript. Unless stated otherwise, all logarithms in this paper are to the base 2. We use [n] to denote the set {1, . . . , n}, where n ≥ 1 is a natural number. We present our model of local computation algorithms (LCAs): Let F be a computational problem and x be an input to F . Let F (x) = {y | y is a valid solution for input x}. The search problem for F is to find any y ∈ F (x).
A (t(n), s(n), δ(n))-local computation algorithm A is a (randomized) algorithm which solves a search problem for F for an input x of size n. However, the LCA A does not output a solution y ∈ F (x), but rather implements query access to y ∈ F (x). A receives a sequence of queries i 1 , . . . , i q and for any q > 0 satisfies the following: (1) after each query i j it produces an output y ij , (2) With probability at least 1 − δ(n) A is consistent, that is, the outputs y i1 , . . . , y iq are substrings of some y ∈ F (x). (3) A has access to a random tape and local computation memory on which it can perform current computations as well as store and retrieve information from previous computations.
We assume that the input x, the local computation tape and any random bits used are all presented in the RAM word model, i.e., A is given the ability to access a word of any of these in one step. The running time of A on any query is at most t(n), which is sublinear in n, and the size of the local computation memory of A is at most s(n). Unless stated otherwise, we always assume that the error parameter δ(n) is at most some constant, say, 1/3. We say that A is a strongly local computation algorithm if both t(n) and s(n) are upper bounded by O(log c n) for some constant c.
Two important properties of LCAs are as follows. We say an LCA A is query order oblivious (query oblivious for short) if the outputs of A do not depend on the order of the queries but depend only on the input and the random bits generated on the random tape of A. We say an LCA A is parallelizable if A supports parallel queries, that is A is able to answer multiple queries simultaneously so that all the answers are consistent.

The problem and our main results
In online algorithms, queries arrive in some unknown order, and the reply to each query depends only on previous queries (but not on any future events). The simplest way to transform online algorithms to LCAs is to process the queries in the order in which they arrive. This, however, means that we have to store the replies to all previous queries, so that even if the time to compute each query is polylogarithmic, the overall space is linear in the number of queries. Furthermore, this means that the resulting LCA is not query-oblivious. The following solution can be applied to this problem ( [13] and [2]): Each query v is assigned a random number, r(v) ∈ [0, 1], called its rank, and the queries are performed in ascending order of rank. Then, for each query x, a query tree can be constructed, to represent the queries on which x depends. If we can show that the query tree is small, we can conclude that each query does not depend on many other queries, and therefore a small number of queries need to be processed in order to reply to query x. We formalize this as follows: Let G = (V, E) be an undirected graph. The vertices of the graph represent queries, and the edges represent the dependencies between the queries. A real number r(v) ∈ [0, 1] is assigned independently and uniformly at random to every vertex v ∈ V ; we call r(v) the rank of v. This models the random permutation of the vertices. Each vertex v ∈ V holds an input x(v) ∈ R, where the range R is some finite set. The input is the content of the query associated with v. A randomized function F is defined inductively on the vertices of G such that F (v) is a (deterministic) function of x(v) as well as the values of F at the neighbors w of v for which r(w) < r(v). F models the output of the online algorithm. We would like to upper bound the number of queries to vertices in the graph needed in order to compute F (v 0 ) for any vertex v 0 ∈ G, namely, the time to simulate the output of query v 0 using the online algorithm.
To upper bound the number of queries to the graph, we turn to a simpler task of bounding the size of a certain d-regular tree, which is an upper bound on the number of queries. Consider an infinite d-regular tree T rooted at v 0 . Each node w in T is assigned independently and uniformly at random a real number r(w) ∈ [0, 1]. For every node w other than v 0 in T , let parent(w) denote the parent node of w. We grow a (possibly infinite) subtree T of T rooted at v as follows: a node w is in the subtree T if and only if parent(w) is in T and r(w) < r(parent(w)) (for simplicity we assume all the ranks are distinct real numbers). That is, we start from the root v 0 , add all the children of v 0 whose ranks are smaller than that of v 0 to T . We keep growing T in this manner where a node w ′ ∈ T is a leaf node in T if the ranks of its d children are all larger than r(w ′ ). We call the random tree T constructed in this way a query tree and we denote by |T | the random variable that corresponds to the size of T . Note that |T | is an upper bound on the number of queries since each node in T has at least as many neighbors as that in G and if a node is connected to some previously queried nodes, this can only decrease the number of queries. Therefore the number of queries is bounded by the size of T . Our goal is to find an upper bound on |T | which holds with high probability.
We improve the upper bound on the query tree of O(log d+1 N ) given in [2] for the case when the degrees are bounded by a constant d and extend our new bound to the case that the degrees of G are binomially distributed, independently and identically with expectation d, i.e., deg(v) ∼ B(n, d/n).
Our main result in this section is bounding, with high probability, the size of the query tree T as follows.

Lemma 1.
Let G be a graph whose vertex degrees are bounded by d or distributed independently and identically from the binomial distribution: deg(v) ∼ B(n, d/n).

Then there exists a constant C(d) which depends only on d, such that
where the probability is taken over all the possible permutations π ∈ Π of the vertices of G, and T is a random query tree in G under π.

Overview of the proof
Our proof of Lemma 1 consists of two parts. Following [2], we partition the query tree into levels. The first part of the proof is an upper bound on the size of a single (sub)tree on any level. For the bounded degree case, this was already proved in [2] (the result is restated as Proposition 1).
We extend the proof of [2] to the binomially distributed degrees case. In both cases the bound is that with high probability each subtree is of size at most logarithmic in the size of the input.
The second part, which is a new ingredient of our proof, inductively upper bounds the number of vertices on each level, as the levels increase. For this to hold, it crucially depends on the fact that all subtrees are generated independently and that the probability of any subtree being large is exponentially small. The main idea is to show that although each subtree, in isolation, can reach a logarithmic size, their combination is not likely to be much larger. We use the distribution of the sizes of the subtrees, in order to bound the aggregate of multiple subtrees.

Bounding the subtree size
As in [2], we partition the query tree into levels and then upper bound the probability that a subtree is larger than a given threshold. Let L > 1 be a function of d to be determined later. First, we partition the interval [0,1] into L sub-intervals: We consider the worst case, in which r(v 0 ) ∈ I 1 . In this case, the vertices on level 1 form a tree T 1 rooted at v 0 . Denote the number of (sub)trees on level i by t i . The vertices on level 2 will form a set of trees {T where the total number of subtrees is at most the sum of the children of all the vertices in T 1 (we only have inequality because some of the children of the vertices of T 1 may be assigned to levels 3 and above.) The vertices on level i > 1 form a set of subtrees {T i } are generated independently by the same stochastic process, as the ranks of all nodes in T are i.i.d. random variables. In the following analysis, we will set L = 3d.
For the bounded degree case, bounding the size of the subtree follows from [2]: 7 Let L ≥ d+1 be a fixed integer and let T be the d-regular infinite query tree. Then for any , for all n ≥ β, where β is some constant. In particular, there is an absolute constant c 0 depending on d only such that for all n ≥ 1,

The binomially distributed degrees case
We are interested in bounding the subtree size also in the case that the degrees are not a constant d, but rather selected independently and identically from a binomial distribution with mean d.
Proof. The proof of Proposition 2 is similar to the proof of Proposition 1 in [2]; we employ the theory of Galton-Watson processes. For a good introduction to Galton-Watson branching processes see e.g. [10].
Consider a Galton-Watson process defined by the probability function p := {p k ; k = 0, 1, 2, . . .}, with p k ≥ 0 and k p k = 1. Let f (s) = In particular, if the process is non-arithmetic, i.e. gcd{r : p r > 0} = 1, and a αf ′′ (a) is finite, then We prove Proposition 2 for the case of tree T 1 -the proof actually applies to all subtrees T and r(w) ∈ I 1 . We repeat this process until there is no vertex that can be added to T 1 .
Once again, we work with the worst case that r(v 0 ) = 1. To upper bound the size of T 1 , we consider a related random process which also grows a subtree of T rooted at v 0 , and denote it by T ′ 1 . The process that grows T ′ 1 is the same as that of T 1 except for the following difference: if v ∈ T ′ 1 and w is a child vertex of v in T , then we add w to T ′ 1 as long as r(w) ∈ I 1 . In other words, we give up the requirement that r(w) < r(v). Clearly, we always have T 1 ⊆ T ′ 1 and hence |T ′ 1 | ≥ |T 1 |.
Note that the random process that generates T ′ 1 is in fact a Galton-Watson process, as the rank of each vertex in T is independently and uniformly distributed in [0, 1]. We take vertex v to be the parent node. Since as the random process that connects w to v and the random process that generates the rank of w are independent (each edge is chosen with probability d/n, and the probability that r(w) is in I v = 1/L). It follows that we have a binomial distribution for the number of child nodes of v in T ′ 1 : where q := d/nL is the probability that a child vertex in T appears in T ′ 1 when its parent vertex is in T ′ 1 . Note that the expected number of children of a vertex in T ′ 1 is nq = d/L < 1, so from the classical result on the extinction probability of Galton-Watson processes (see e.g. [10]), the tree T ′ 1 is finite with probability one. The generating function of p is as the probability function {p k } obeys the binomial distribution p k = Pr[X = k] where X ∼ B(n, q). In addition, the convergence radius of f is ρ = ∞ since {p k } has only a finite number of non-zero terms.
We can lower bound α as Finally we calculate f ′′ (a): is a bounded constant. Now applying Theorem 1 to the Galton-Watson process which generates T ′ 1 (note that t = 1 in our case) gives that, there exists a constant n 0 such that for n > n 0 , for all n > n 0 . Hence for all large enough n, with probability at least 1 − 1/n 3 , The following corollary stems directly from Propositions 1 and 2:

Bounding the increase in subtree size as we go up levels
From Corollary 1 we know that the size of any subtree, in particular |T 1 |, is bounded by O(log n) with probability at least 1 − 1/n 3 in both the degree d and the binomial degree cases. Our next step in proving Lemma 1 is to show that, as we increase the levels, the size of the tree does not increase by more than a constant factor for each level. That is, there exists an absolute constant η depending on d only such that if the number of vertices on level k is at most |T k |, then the number of vertices on level k + 1, Since there are L levels in total, this implies that the number of vertices on all L levels is at most O((2η) L log n) = O(log n).
The following Proposition establishes our inductive step.
Proof. Denote the number of vertices on level k by Z k and let Notice that, given Y k (the number of nodes up to level k), there are at most Z k+1 +Y k −1 We want to bound the probability that Z k+1 = ηY k for some (large enough) constant η > 0. We can bound this as follows: It follows that there is some absolute constant c ′ which depends on d only such that Pr[|T k+1 | ≥ ηY k ] ≤ e −c ′ ηY k . That is, if ηY k = Ω(log n), the probability that |T k+1 | ≥ ηY k is at most 1/n 3 . Adding the vertices on all L levels and applying the union bound, we conclude that with probability at most 1/n 2 , the size of T is at most O(log n).

Hypergraph 2-coloring and k-CNF
We use the bound on the size of the query tree of graphs of bounded degree to improve the analysis of [2] for hypergraph 2-coloring. We also modify their algorithm slightly to further improve the algorithm's complexity. As the algorithm is a more elaborate version of the algorithm of [2] and the proof is somewhat long, we only state our main theorem for hypergraph 2-coloring; we defer the proof to Appendix A. Due to the similarity between hypergraph 2-coloring and k-CNF, we also have the following theorem; the proof is in Appendix B.

Theorem 3.
Let H be a k-CNF formula with k ≥ 2. Suppose that each clause intersects no more than d other clauses, and furthermore suppose that k ≥ 16 log d + 19. Then there exists a (O(log 4 n), O(log 4 n), 1/n)-local computation algorithm which, given a formula H and any sequence of queries to the truth assignments of variables (x 1 , x 2 , . . . , x s ), with probability at least 1 − 1/n 2 , returns a consistent truth assignment for all x i 's which agrees with some satisfying assignment of the k-CNF formula H. Moreover, the algorithm is query oblivious and parallelizable.

Maximal matching
We consider the problem of maximal matching in a bounded-degree graph. We are given a graph G = (V, E), where the maximal degree is bounded by some constant d, and we need to find a maximal matching.A matching is a set of edges with the property that no two edges share a common vertex. The matching is maximal if no other edge can be added to it without violating the matching property.
Assume the online scenario in which the edges arrive in some unknown order. The following greedy online algorithm can be used to calculate a maximal matching: When an edge e arrives, we check whether e is already in the matching. If it is not, we check if any of the neighboring edges are in the matching. If none of them is, we add e to the matching. Otherwise, e is not in the matching.
We turn to the local computation variation of this problem. We would like to query, for some edge e ∈ E, whether e is part of some maximal matching. (Recall that all replies must be consistent with some maximal matching).
We use the technique of [2] to produce an almost O(log n)-wise independent random ordering on the edges, using a seed length of O(log 3 n). 8 When an edge e is queried, we use a BFS (on the edges) to build a DAG rooted at e. We then use the greedy online algorithm on the edges of the DAG (examining the edges with respect to the ordering), and see whether e can be added to the matching.
As the query tree is an upper-bound on the size of the DAG, we derive the following theorem from Lemma 1.

The bipartite case and local load balancing
We consider a general "power of d choices" online algorithm for load balancing. In this setting there are n balls that arrive in an online manner, and m bins. Each ball selects a random subset of d bins, and queries these bins. (Usually the query is simply the current load of the bin.) Given this information, the ball is assigned to one of the d bins (usually to the least loaded bin). We denote by LB such a generic algorithm (with a decision rule which can depend in an arbitrary way on the d bins that the ball is assigned to). Our main goal is to simulate such a generic algorithm.
The load balancing problem can be represented by a bipartite graph G = ({V, U }, E), where the balls are represented by the vertices V and the bins by the vertices U . The random selection of a bin u ∈ U by a ball v ∈ V is represented by an edge. By definition, each ball v ∈ V has degree d. Since there are random choices in the algorithm LB we need to specify what we mean by a simulation. For this reason we define the input to be the following: a graph G = ({V, U }, E), where |V | = n, |U | = m, and n = cm for some constant c ≥ 1. We also allocate a rank r(u) ∈ [0, 1] to every u ∈ U . This rank represents the ball's arrival time: if r(v) < r(u) then vertex v arrived before vertex u. Furthermore, all vertices can have an input value x(w). (This value represents some information about the node, e.g., the weight of a ball.) Given this input, the algorithm LB is deterministic, since the arrival sequence is determined by the ranks, and the random choices of the balls appear as edges in the graph. Therefore by a simulation we will mean that given the above input, we generate the same allocation as LB.
We consider the following stochastic process: Every vertex v ∈ V uniformly and independently at random chooses d vertices in U . Notice that from the point of view of the bins, the number of balls which chose them is distributed binomially with X ∼ B(n, d/m). Let X v and X u be the random variables for the number of neighbors of vertices v ∈ V and u ∈ U respectively. By definition, X v = d, since all balls have d neighbors, and hence each X u is independent of all X v 's. However, there is a dependence between the X u 's (the number of balls connected to different bins). Fortunately this is a classical example where the random variables are negatively dependent (see e.g. [9]). 9

The bipartite case
Recall that in Section 3, we assumed that the degrees of the vertices in the graph were independent. We would like to prove an O(log n) upper bound on the query tree T for our bipartite graph. As we cannot use the theorems of Section 3 directly, we show that the query tree is smaller than another query tree which meets the conditions of our theorems.
The query tree for the binomial graph is constructed as follows: a root v 0 ∈ V is selected for the tree. (v 0 is the ball whose bin assignment we are interested in determining.) Label the vertices at depth j in the tree by W j . Clearly, W 0 = {v 0 }. At each depth d, we add vertices one at a time to the tree, from left to right, until the depth is "full" and then we move to the next depth. Note that at odd depths (2j + 1) we add bin vertices and at even depths (2j) we add ball vertices.
Specifically, at odd depths (2j + 1) we add, for each v ∈ W 2j its d neighbors u ∈ N (v) as children, and mark each by u. 10 At even depths (2j) we add for each node marked by u ∈ W 2j−1 all its (ball) neighbors v ∈ N (u) such that r(v) < r(parent(u)), if they have not already been added to the tree. Namely, all the balls that are assigned to u by time A leaf is a node marked by a bin u ℓ for whom all neighboring balls v ∈ N (u ℓ ) − {parent(u ℓ )} have a rank larger than its parent, i.e., r(v) > r(parent(u ℓ )). Namely, parent(u ℓ ) is the first ball to be assigned to bin u ℓ . This construction defines a stochastic process F = {F t }, where F t is (a random variable for) the size of T at time t. (We start at t = 0 and t increases by 1 for every vertex we add to the tree).
We now present our main lemma for bipartite graphs.
where the probability is taken over all of the possible permutations π ∈ Π of the vertices of G, and T is a random query tree in G under π.
To prove Lemma 2, we look at another stochastic process F ′ , which constructs a tree T ′ : we start with a root v ′ 0 . Label the vertices at depth j in the tree by W ′ j . Assign every vertex y that is added to the tree a rank r(y) ∈ [0, 1] independently and uniformly at random. Similarly to T , 2j , d children (from left to right). At even depths (2j) we add to each node Of the nodes added in this level, we remove all those vertices y ′ for which r(y ′ ) > r(parent(parent(y ′ ))).
Importantly, the neighbor distributions of the vertices in the tree are independent of each other. If at any point T ′ has "more than half the bins", i.e., the sum of nodes on odd levels is at least m/2, we add n + m bin children of rank 0 to some even-level node in the tree.
Given a tree T we define squash(T ) to be the tree T with the odd levels deleted, and a node v in level 2j is connected to node v ′ in level 2j + 2 if v = parent(parent(v ′ )). Because d·|squash(T ′ )| ≥ |T ′ | ≥ |squash(T ′ )|, we immediately get the following corollary: There is a constant C(d) which depends only on d such that for all large enough n, Pr[|T ′ | > C(d) log n] < 1/n 2 .
We first make the following claim: 2j has d children, each with degree distributed binomially ∼ B(n, 2d/m). B(qn, p). The Claim follows.

⊓ ⊔
We can now turn to the proof of Lemma 3: Proof. As long as |squash(T ′ )| < m/2, the proof of the lemma follows the proof of Lemma 1 with slight modifications to constants and will therefore be omitted.
We notice that |squash(T ′ )| < m/2 w.p. at least 1 − 1/n 2 : the proof of Lemma 1 is inductive -we show that at level I 1 , the size of the subtree is at most O(log n), and then bound the increase in tree size as we move to the next level. By the level I L , |squash(T ′ )| = O(log n) w.p. at least 1−1/n 2 . Therefore it follows that |squash(T ′ )| < m/2 w.p. at least 1 − 1/n 2 .
⊓ ⊔ Before we can complete the proof of Lemma 2, we need to define the notion of first order stochastic dominance: First order stochastic dominance). We say a random variable X first order stochastically dominates (dominates for short) a random variable Proof. Assume we add a (bin) vertex u ∈ U to T at time t, the random variable for the number of u's neighbors is negatively dependent on all other X w , w ∈ T t ∩ U . We label this variableX = X u |{X w }, w ∈ T t . We first show that F ′ t ≥ F t when T has less than m/2 bins, and then show that F ′ t ≥ F t when T ′ has more than m/2 bins. (It is easy to see why this is enough). Assume |T t ∩U | ≤ m/2. X u is dependent on at most m/2 other random variables, X w . Because the dependency is negative, X u is maximized when ∀w, X w = 0. Therefore, in the worst case, X u is dependent on m/2 bins with 0 children. If m/2 bins have 0 children, all edges in G must be distributed between the remaining bins. Thereforē X ≤ X ′ u , where X ′ u ∼ B(n, 2d/m). When T ′ has more than m/2 bins, by the construction of F ′ t , it has more than m + n vertices, and so F ′ t trivially dominates F t .

⊓ ⊔
Combining Corollary 2 and Lemma 4 completes the proof of Lemma 2.

Local load balancing
The following theorem states our basic simulation result. We first build a query tree as follows: Let v 0 be the root of the tree. For every u ∈ N (u 0 ), add to the tree the neighbors of u, v ∈ V such that r(v) < r(v 0 ). Continue inductively until either K nodes have been added to the random query tree or no more nodes can be added to it. If K nodes have been added to the query tree, this is a failure event, and assign to v 0 a random bin in N (v 0 ). From Lemma 2, this happens with probability at most 1/n 2 , and so the probability that some failure event will occur is at most 1/n. Otherwise, perform LB on all of the vertices in the tree, in order of addition to the tree, and output the bin to which ball v 0 is assigned to by LB.
⊓ ⊔ A reduction from various load balancing algorithms gives us the following corollaries to Theorem 5.

Random ordering
In the above we assume that we are given a random ranking for each ball. If we are not given such random rankings (in fact, a random permutation of the vertices in U will also suffice), we can generate a random ordering of the balls. Specifically, since w.h.p. the size of the random query is O(log n), an O(log n)-wise independent random ordering 12 suffices for our local computation purpose. Using the construction in [2] of 1/n 2 -almost O(log n)-wise independent random ordering over the vertices in U which uses space O(log 3 n), we obtain (O(log 3 n), O(log 3 n), 1/n)-local computation algorithms for balls and bins.

A Hypergraph two-coloring
Recall that a hypergraph H is a pair H = (V, E) where V is a finite set whose elements are called nodes or vertices, and E is a family of non-empty subsets of V , called hyperedges. A hypergraph is called k-uniform if each of its hyperedges contains precisely k vertices. A two-coloring of a hypergraph H is a mapping c : V → {red, blue} such that no hyperedge in E is monochromatic. If such a coloring exists, then we say H is two-colorable. We assume that each hyperedge in H intersects at most d other hyperedges. Let n be the number of hyperedges in H. Here we think of k and d as fixed constants and all asymptotic forms are with respect to n. By the Lovász Local Lemma, when e(d + 1) ≤ 2 k−1 , the hypergraph H is two-colorable (e.g. [1]).
Following [17], we let m be the total number of vertices in H. Note that m ≤ kn, so m = O(n). For any vertex x ∈ V , we use E(x) to denote the set of hyperedges x belongs to. For any hypergraph H = (V, E), we define a vertex-hyperedge incidence matrix M ∈ {0, 1} m×n so that, for every vertex x and every hyperedge e, M x,e = 1 if and only if e ∈ E(x). Because we assume both k and d are constants, the incidence matrix M is necessarily very sparse. Therefore, we further assume that the matrix M is implemented via linked lists for each row (that is, vertex x) and each column (that is, hyperedge e).
Let G be the dependency graph of the hyperedges in H. That is, the vertices of the undirected graph G are the n hyperedges of H and a hyperedge E i is connected to It is easy to see that if the input hypergraph is given in the above described representation, then we can find all the neighbors of any hyperedge E i in the dependency graph G (there are at most d of them) in constant time (which depends on k and d).
A natural question to ask is: Given a two-colorable hypergraph H, and a vertex v, Our main result in this section is, given a two-colorable hypergraph H whose twocoloring scheme is guaranteed by the Lovász Local Lemma (with slightly weaker parameters), we give a (O(log 4 n), O(log 4 n), 1/n) -local computation algorithm. We restate our main theorem: In fact, we only need: Throughout the following analysis, we set: k 1 = k, and Notice that the theorem's premise simply implies that 2 k4−1 ≥ e(d + 1), as required by the Lovász Local Lemma.

A.1 The general phase -random coloring
In each phase we begin with subsets V i and E i of V and E, such that each edge contains at least k i vertices. We sequentially assign colors at random to the vertices, as long as every monochromatic edge has at least k i+1 uncolored vertices. Once the phase is over we do not change this assignment.
If an edge has all of its vertices besides k i+1 colored in one color, it is labeled dangerous. All the uncolored vertices in a dangerous edge are labeled saved and we do not color them in this phase. We proceed until all vertices in V i are either red, blue, or saved. Let the survived hyperedges be all the edges that do not contain both red and blue vertices. Each survived edge contains some vertices colored in one color, and at least k i+1 saved vertices.
Let S i be the set of survived edges after a random coloring in Phase i, and consider G| Si , the restriction of G to S i The probability that G| Si contains a connected component of size d 3 u at most |V i |2 −u ([1]). In particular, after repeating the random coloring procedure t i times, there is no connected component of size greater than d 3 u with probability If the query vertex x has been assigned a color in the i-th phase, we can simply return this color. Otherwise, if it is a saved vertex we let C i (x) be the connected component containing x in G| Si . Finally, since the coloring of C i (x) is independent of all other uncolored vertices, we can restrict ourselves to E i+1 = C i (x) in the next phase.

A.2 Phase 1: partial random coloring
In the first phase we begin with the whole hypergraph, i.e. V 1 = V , E 1 = E, and k 1 = k. Thus, we cannot even assign a random coloring to all the vertices in sublinear complexity. Instead, similarly to the previous sections, we randomly order the vertices of the hypergraph and use a query tree to randomly assign colors to all the vertices that arrive before x and may influence it. Note that this means that we can randomly assign the colors only once.
If x is a saved vertex, we must compute E 2 = C 1 (x), the connected component containing x in G| S1 . Notice that the size C 1 (x) is bounded w.h.p.
Pr |C 1 (x)| > 4d 3 log n < n2 −4 log n = n −3 In order to compute C 1 (x), we run BFS on G| S1 . Whenever we reach a new node, we must first randomly assign colors to the vertices in its query tree, like we did for x's query tree. Since (w.h.p.) there are at most O(log n) edges in C 1 (x), we query for trees  Finally, since we are only interested in O log 2 (n) vertices, we may consider a coloring which is only O log 2 (n) -wise independent, and a random ordering which is only n −3 -almost O log 2 (n) -independent. Given the construction in [2], this can be done in space and time complexity O log 4 (n)

A.3 Phase 2 and 3: gradually decreasing the component size
Phase 2 and 3 are simply iterations of the general phase with parameters as described below. With high probability we have that |E 2 | ≤ 4d 3 log n, and each edge has k 2 uncolored vertices. After at most t 2 = log n repetitions of the random coloring procedure, we reach an assignment that leaves a size 2d 3 log log n-connected component of survived edges with probability 4d 3 k 2 log n 2 −2 log log n log n < n −3 Similarly, in the third phase we begin with |E 3 | < 2d 3 log log n, and after t 3 = log n repetitions we reach an assignment that leaves a size log log n k4 -connected component of survived edges with probability  , and each edge has k 4 uncolored vertices. By the Lovasz Local Lemma, there must exists a coloring (see e.g. Theorem 5.2.1 in [1]). We can easily find this coloring via brute force search in time O(log n).

B k-CNF
As another application, our hypergraph coloring algorithm can be easily modified to compute a satisfying assignment of a k-CNF formula, provided that the latter satisfies some specific properties.
Let H be a k-CNF formula on m Boolean variables x 1 , . . . , x m . Suppose H has n clauses H = A 1 ∧ · · · ∧ A n and each clause consists of exactly k distinct literals. 13 We say two clauses A i and A j intersect with each other if they share some variable (or the negation of that variable). As in the case for hypergraph coloring, k and d are fixed constants and all asymptotics are with respect to the number of clauses n (and hence m, since m ≤ kn). Our main result is the following.

Theorem 7.
Let H be a k-CNF formula with k ≥ 2. Suppose that each clause intersects no more than d other clauses, and furthermore suppose that k ≥ 16 log d + 19. Then there exists a (O(log 4 n), O(log 4 n), 1/n)-local computation algorithm which, given a formula H and any sequence of queries to the truth assignments of variables (x 1 , x 2 , . . . , x s ), with probability at least 1 − 1/n 2 , returns a consistent truth assignment for all x i 's which agrees with some satisfying assignment of the k-CNF formula H. Moreover, the algorithm is query oblivious and parallelizable.

Proof [Sketch]:
We follow a 4-phase algorithm similar to that of hypergraph twocoloring as presented in appendix A. In every phase, we sequentially assign random values to a subset of the remaining variables, maintaining a threshold of k i unassigned variables in each unsatisfied clause. Since the same (in fact, slightly stronger) bounds that hold for the connected components in the hyperedges dependency graph also hold for the clauses dependency graph ( [17]), we can return an answer which is consistent with a satisfying assignment with probability at least 1 − 1/n 2 . ⊓ ⊔

C Lower bound on the size of the query tree
We prove a lower bound on the size of the query tree. Theorem 8. Let G be a random graph whose vertex degree is bounded by d ≥ 2 or distributed independently and identically from the binomial distribution: deg(v) ∼ B(n, d/n) (d ≥ 2). Then Pr[|T | > log n/ log log n] > 1/n, where the probability is taken over all random permutations π ∈ Π of the vertices, and T is the largest query tree in G (under π).
Proof. For both the bounded degree and the binomial distribution cases, there exists a path of length at least k = log n/ log log n in the graph w.h.p. Label the vertices on the path v 1 , v 2 , . . . , v k . There are k! possible permutations of the weights of the vertices on the path. The probability of choosing the permutation in which w(v 1 ) < w(v 2 ) < . . . < (v k ) is 1/k!. k! = (log n/ log log n)! < (log n/ log log n) log n/ log log n < n.
Therefore, 1/k! > 1/n and so the probability of the query tree having size log n/ log log n is at least 1/n. ⊓ ⊔