DeepAI

# Resolving Conflicts and Electing Leaders

We review distributed algorithms for transmitting data (n real numbers) under a broadcast communication model, as well as for maximum finding and for sorting. Our interest is in the basics of recursive formulas and corresponding asymptotics as n→∞. The emphasis is on concrete examples rather than general theory.

12/29/2017

### Sorting Real Numbers in O(n√( n)) Time and Linear Space

We present an O(n√( n)) time and linear space algorithm for sorting real...
02/07/2020

### Recursive PGFs for BSTs and DSTs

We review fundamentals underlying binary search trees and digital search...
06/12/2019

### Broadcasts on Paths and Cycles

A broadcast on a graph G=(V,E) is a function f: V⟶{0,...,diam(G)} such t...
07/04/2018

### A complete system of deduction for Sigma formulas

The Sigma formulas of the language of arithmetic express semidecidable r...
01/23/2020

### Communication-Efficient String Sorting

There has been surprisingly little work on algorithms for sorting string...
09/05/2018

### Data Lakes, Clouds and Commons: A Review of Platforms for Analyzing and Sharing Genomic Data

We review software platforms for managing, analyzing and sharing biomedi...
04/26/2019

### Countably Infinite Multilevel Source Polarization for Non-Stationary Erasure Distributions

Polar transforms are central operations in the study of polar codes. Thi...

## 1 Conflict Resolutions

Consider the R program:

 {f <- function(L,k)}{{}{\ \ if(NROW(L)<=1) {}{\ \ \ \ k}{\ \ } else {}{\ \ \ \ b <- rbinom(NROW(L),1,0.5)}{\ \ \ \ L1 <- L[(1:NROW(L))*(1-b)]}{\ \ \ \ k <- f(L1,k <- k+1)}{\ \ \ \ L2 <- L[(1:NROW(L))*b]}{\ \ \ \ k <- f(L2,k <- k+1)}{\ \ }}{\ \ k}{}}

where the integer is initially , the list is initially for simplicity’s sake, and is the built-in R unbiased random Bernoulli generator.  Figure 1 exhibits a sample binary tree for .  The first round of coin tosses yields , where and , and thus , .  On the left side, focusing on only, the next round of tosses yields and thus , .  On the right side, focusing on only, the next round of tosses yields and thus , .  Also, focusing on only, the next round of tosses yields and thus , .  Termination occurs at the next level: any twig of the tree ceases to grow when its leaf contains items.  The number of vertices (including empty vertices) is .  We write .  The labeled ordering of vertices is determined by watching increase, from to , as the algorithm progresses.  Smaller values of occur on the left side because recursive splitting starts with , , … and thereafter continues with , , , ….

The probability generating function for

, given , is likewise recursive [3]:

 fn(z)=z2−nn∑k=0(nk)fk(z)fn−k(z),n≥2;
 f0(z)=f1(z)=z.

Note that always.  Differentiating with respect to :

 f′n(z)=2−nn∑k=0(nk)fk(z)fn−k(z)+z2−nn∑k=0(nk)[f′k(z)fn−k(z)+fk(z)f′n−k(z)]

we have first moment

 E(Xn) =f′n(1)=1+2−nn∑k=0(nk)[f′k(1)+f′n−k(1)] =1+21−nn∑k=0(nk)f′k(1),

that is,

 gn =1+21−nn∑k=0(nk)gk =11−21−n[1+21−nn−1∑k=0(nk)gk]

where and .  Clearly and .  Differentiating again:

 f′′k(z) =21−nn∑k=0(nk)[f′k(z)fn−k(z)+fk(z)f′n−k(z)] +2−nn∑k=0(nk)[f′′k(z)fn−k(z)+2f′k(z)f′n−k(z)+fk(z)f′′n−k(z)]

we have second factorial moment

 E(Xn(Xn−1)) =f′′n(1) =−2+2f′n(1)+21−nn∑k=0(nk)f′k(1)f′n−k(1)+21−nn∑k=0(nk)f′′k(1),

that is,

 hn =−2+2gn+21−nn∑k=0(nk)gkgn−k+21−nn∑k=0(nk)hk =11−21−n[−2+2gn+21−nn∑k=0(nk)gkgn−k+21−nn−1∑k=0(nk)hk]

where and .  Clearly and

.  Finally, we have variance

 V(Xn)=hn−g2n+gn

which is when and when .

Such recursions are helpful for small , but give no asymptotic information as .  It can be proved that [4, 5]

 E(Xn)n =2ln(2)+δ1(ln(n)ln(2))+o(1) ≈(2.8853900817...)+δ1(log2(n)),
 V(Xn)n =1ln(2)(1+8∞∑k=11(2k+1)2)+δ2(ln(n)ln(2))+o(1) ≈(3.3834344923...)+δ2(log2(n))

where is a periodic function of period with tiny amplitude and zero mean, for , .  Functions like these appear throughout the analysis of algorithms.  We shall not specify these here nor later, but merely indicate their presence when required.  An infinite series representation of the mean for arbitrary is [6, 7]

 E(Xn)=1+2∞∑m=02m[1−(1−2−m)n−n2−m(1−2−m)n−1].

Also, the constant (one-quarter of the variance as ) appears in [8, 9, 10].

Two parameters are examined in this section: height (length of the root-to-leaf path that gives the leader) and size (number of vertices in the associated weakly binary tree).  We further discuss a variation of the election in which draws (involving exactly two competitors) constitute an additional way to stop the process.

### 2.1 Height

Consider the R program:

 {f <- function(L,k)}{{}{\ \ if(NROW(L)<=1) {}{\ \ \ \ k}{\ \ } else {}{\ \ \ \ b <- rbinom(NROW(L),1,0.5)}{\ \ \ \ L1 <- L[(1:NROW(L))*(1-b)]}{\ \ \ \ k <- f(L1,k <- k+1)}{\ \ \ \ if(NROW(L1)==0) {}{\ \ \ \ \ \ L2 <- L[(1:NROW(L))*b]}{\ \ \ \ \ \ k <- f(L2,k)}{\ \ \ \ }}{\ \ }}{\ \ k}{}}

where the integer is initially (unlike before) and the list is initially .  Figure 2 exhibits a sample binary tree for .  The first round of coin tosses yields , where and , and thus , .  Focusing on only, the next round of tosses yields and thus , .  Note that we do not indicate nor count the empty vertex. Focusing on only, the next round of tosses yields and thus , .  Focusing on only, the next round of tosses yields and thus , .  Focusing on only, the next round of tosses yields and thus , .  Termination occurs at the next level: the leftmost twig of the tree contains exactly item.  The height (number of steps separating the vertices labeled and ) is . We write .

The probability generating function for , given , is [11]:

 fn(z)=−z2−n+z2−nfn(z)+z2−nn∑k=0(nk)fk(z),n≥2;
 f0(z)=f1(z)=1.

Note that always.  Differentiating with respect to :

 f′n(z)=−2−n+2−nfn(z)+z2−nf′n(z)+2−nn∑k=0(nk)fk(z)+z2−nn∑k=0(nk)f′k(z)

we have first moment

 E(Hn) =f′n(1)=−2−n+2−n+2−nf′n(1)+1+2−nn∑k=0(nk)f′k(1) =1+2−nf′n(1)+2−nn∑k=0(nk)f′k(1),

that is,

 gn =1+2−ngn+2−nn∑k=0(nk)gk =11−21−n[1+2−nn−1∑k=0(nk)gk]

where and .  Clearly and .  Differentiating again:

 f′′n(z)=21−nf′n(z)+z2−nf′′n(z)+21−nn∑k=0(nk)f′k(z)+z2−nn∑k=0(nk)f′′k(z)

we have second factorial moment

 E(Hn(Hn−1)) =f′′n(1) =−2+2f′n(1)+2−nf′′n(1)+2−nn∑k=0(nk)f′′k(1),

that is,

 hn =−2+2gn+2−nhn+2−nn∑k=0(nk)hk =11−21−n[−2+2gn+2−nn−1∑k=0(nk)hk]

where and .  Clearly and .  Finally, we have variance which is when and when .

It can be proved that [12, 13, 14]

 E(Hn) =ln(n)ln(2)+12+δ3(ln(n)ln(2))+o(1) ≈log2(n)+(0.5)+δ3(log2(n)),
 V(Hn) =112+π26ln(2)2−γ2+2γ1ln(2)2+ε(ln(n)ln(2))+o(1) ≈(3.1166951643...)+ε(log2(n))

as , where is the first Stieltjes constant [15] and fluctuations provided by are symmetrical not about , but instead about [16]

 1∫0ε(x)dx=−1ln(2)2∞∑k=−∞k≠0∣∣ ∣∣ζ(1−2πikln(2))Γ(1−2πikln(2))∣∣ ∣∣2≈−1.856×10−10.

Needless to say, the evaluation of is an impressive and difficult achievement.

### 2.2 Size

Consider the R program:

 {f <- function(L,k)}{{}{\ \ if(NROW(L)<=1) {}{\ \ \ \ k}{\ \ } else {}{\ \ \ \ b <- rbinom(NROW(L),1,0.5)}{\ \ \ \ L1 <- L[(1:NROW(L))*(1-b)]}{\ \ \ \ L2 <- L[(1:NROW(L))*b]}{\ \ \ \ k <- f(L1,k <- k+(NROW(L1)!=0)+(NROW(L2)!=0))}{\ \ \ \ if(NROW(L1)==0) {}{\ \ \ \ \ \ k <- f(L2,k)}{\ \ \ \ }}{\ \ }}{\ \ k}{}}

where the integer is initially and the list is initially .  Figure 3 is almost identical to Figure 2 – it contains the same binary tree for – but the labeling is different.  The number of vertices (excluding empty vertices) is .  We write .  The labeled ordering of vertices is determined by watching increase, from to , as the algorithm progresses.  We sweep across the tree horizontally (in rows) rather than hierarchically.  In particular, the command

 {k <- k+(NROW(L1)!=0)+(NROW(L2)!=0)}

increases by if both vertices are non-empty and by only if otherwise.

The probability generating function for , given , is [11]:

 fn(z)=−z22−n+(2z−z2)2−nfn(z)+z22−nn∑k=0(nk)fk(z),n≥2;
 f0(z)=1,f1(z)=z.

Note that always.  Differentiating with respect to :

 f′n(z) =−z21−n+(1−z)21−nfn(z)+(2z−z2)2−nf′n(z) +z21−nn∑k=0(nk)fk(z)+z22−nn∑k=0(nk)f′k(z)

we have first moment

 E(Yn) =f′n(1)=−21−n+0+2−nf′n(1)+2+2−nn∑k=0(nk)f′k(1) =2−21−n+2−nf′n(1)+2−nn∑k=0(nk)f′k(1),

that is,

 gn =(1−21−n)+1+2−ngn+2−nn∑k=0(nk)gk =1+11−21−n[1+2−nn−1∑k=0(nk)gk]

where and , .  Clearly and .  Differentiating again:

 f′′n(z) =−21−n−21−nfn(z)+(1−z)22−nf′n(z)+(2z−z2)2−nf′′n(z) +21−nn∑k=0(nk)fk(z)+z22−nn∑k=0(nk)f′k(z)+z22−nn∑k=0(nk)f′′k(z)

we have second factorial moment

 E(Yn(Yn−1)) =f′′n(1) =−22−n+0+2−nf′′n(1)+2+22−nn∑k=0(nk)f′k(1)+2−nn∑k=0(nk)f′′k(1),

that is,

 hn =2(1−21−n)+2−nhn+22−nn∑k=0(nk)gk+2−nn∑k=0(nk)hk =2+11−21−n[22−nn∑k=0(nk)gk+2−nn−1∑k=0(nk)hk]

where and .  Clearly and .  Finally, we have variance which is when and when .

It can be proved that [11]

 E(Yn) =2ln(n)ln(2)+(2−ln(π)−γln(2))+δ4(ln(n)ln(2))+o(1) ≈2log2(n)+(1.1812500478...)+δ4(log2(n))

as , but a comparable asymptotic expression for remains unknown.

We wonder about the cross-covariance of and , whose calculation would require a bivariate generating function.

### 2.3 Draws

Let us alter the rules so that a draw between two persons is allowed (if precisely two persons are left, then they both are declared leaders).  The third line of the two preceding R programs is simply replaced by

 {if(NROW(L)<=2) {}

and the initial conditions of the two preceding recurrences are also changed.  For height, we now have (implying and (implying ); thus

 E(~Hn) =ln(n)ln(2)+(12−π212ln(2))+δ5(ln(n)ln(2))+o(1) ≈log2(n)−(0.6865691104...)+δ5(log2(n)).

For size, we now have , (implying and (implying ); thus

 E(~Yn) =2ln(n)ln(2)+⎛⎜⎝2−ln(π)−γ+π28ln(2)⎞⎟⎠+δ6(ln(n)ln(2))+o(1) ≈2log2(n)−(0.5986036178...)+δ6(log2(n)).

It would seem that the fraction given within the formula for in [11] is incorrect and should be instead.

## 3 Coin Tosses

Before moving on to more complicated examples, it may be worthwhile to contemplate the most elementary recursive program imaginable:

 {f <- function(L,k)}{{}{\ \ if(NROW(L)==0) {}{\ \ \ \ k}{\ \ } else {}{\ \ \ \ b <- rbinom(NROW(L),1,0.5)}{\ \ \ \ L1 <- L[(1:NROW(L))*(1-b)]}{\ \ \ \ k <- f(L1,k <- k+1)}{\ \ }}{\ \ k}{}}

mentioned at the end of [17], where is initially .  Note that the third line here is

 {if(NROW(L)<=0) {}

unlike what we have seen before.  People iteratively toss all coins which show tails until only heads are visible. Omitting details, it follows that the procedural height has generating function

 fn(z)=z2−nn∑k=0(nk)fk(z),n≥1;
 f0(z)=1

therefore

 gn=1+2−nn∑k=0(nk)gk=11−2−n[1+2−nn−1∑k=0(nk)gk],
 hn=−2+2gn+2−nn∑k=0(nk)hk=11−2−n[−2+2gn+2−nn−1∑k=0(nk)hk]

where (implying , , and (implying , , ).  From this [18]

 E(^Hn) =ln(n)ln(2)+(12+γln(2))+δ7(ln(n)ln(2))+o(1) ≈log2(n)+(1.3327461772...)+δ7(log2(n)),
 V(^Hn) =(112+π26ln(2)2)+δ8(ln(n)ln(2))+o(1) ≈(3.5070480758...)+δ8(log2(n))

as .

## 4 Finding the Maximum

Consider the R program:

 {f <- function(L,k,r)}{{}{\ \ if(NROW(L)==0) {}{\ \ \ \ c(k,r)}{\ \ } else if(NROW(L)==1) {}{\ \ \ \ c(k,r <- max(L,r))}{\ \ } else {}{\ \ \ \ b <- rbinom(NROW(L),1,0.5)}{\ \ \ \ L0 <- L[(1:NROW(L))*b]}{\ \ \ \ L1 <- L[(1:NROW(L))*(1-b)]}{\ \ \ \ V <- f(L1,k <- k+1,r)}{\ \ \ \ k <- V[1]; r <- V[2]}{\ \ \ \ L2 <- L0[L0>r]}{\ \ \ \ V <- f(L2,k <- k+1,r)}{\ \ \ \ k <- V[1]; r <- V[2]}{\ \ }}{\ \ c(k,r)}{}}

where the integer is initially and the list is initially .  We find a comparison of a conflict resolution tree in Figure 4 and its corresponding maximum-finding tree in Figure 5 to be helpful.  Note that the vertex count for the latter is only , which is less than the vertex count of determined for the former.  The discrepancy arises because, at the instant the vertex becomes the leader and consequently increases from to , both the vertex becomes empty and the & vertices are reduced to .  It follows that the vertex is reduced to , which cannot have any descendants, eliminating two twigs.  Also, increases from to and, subsequently, from to ; while the penultimate vertex becomes empty, this does not further alter the count.  We write .

The probability generating function for , given , is [19, 20, 21, 22]:

 fn(z)=z22−nfn(z)+z2−nn∑k=1fn−k(z)k∑j=1(k−1j−1)fj(z),n≥2;
 f0(z)=f1(z)=z.

Note that always.  When differentiating with respect to :

 f′n(z) =z21−nfn(z)+z22−nf′n(z)+2−nn∑k=1fn−k(z)k∑j=1(k−1j−1)fj(z) +z2−nn∑k=1f′n−k(z)k∑j=1(k−1j−1)fj(z)+z2−nn∑j=1f′j(z)n∑k=j(k−1j−1)fn−k(z)

we make use of the identity

 n∑k=1k∑j=1akj=n∑j=1n∑k=jakj.

From this follows the first moment:

 E(Xn) =f′n(1)=21−n+2−nf′n(1)+2−n(−1+2n)+2−nn∑k=12−1+kf′n−k(1)+2−nn∑j=1(nj)f′j(1) =1−2−n+21−n+2−nf′n(1)+n∑k=12−1−n+kf′n−k(1)+2−nn−1∑j=0(nj)f′j(1)−2−n+2−nf′n(1) =1+21−nf′n(1)+n−1∑i=02−i−1f′i(1)+2−nn−1∑j=0(n)jf′j(1)

setting , hence and when .  That is,

 gn =1+21−ng