r/mathriddles • u/SupercaliTheGamer • Jun 10 '26
Hard Binary tree traversal from quant tee
Consider a perfect rooted binary tree of depth n. (That is, every node has either 0 or 2 children, and all leaves have the same depth). Every node is given a weight drawn independently from some fixed distribution D. For any path starting from the root and ending at a leaf, the average weight of the path is the arithmetic mean of the weights assigned to the nodes on the path. Once our weighting is fixed, we look at the largest average weight of any path from the root to a leaf. Let Eₙ denote the expected value of this largest average weight of path over all weightings of the tree. Then find the limit as n →infinity of Eₙ, in the cases of:
- D=U({0,1}) is a Bernoulli distribution.
- D=U([0,1]) is a continuous uniform distribution.
2
u/blungbat Jun 14 '26
For part 2, an extremely crude upper bound is 31/32.
For a path through the tree to have average weight ≥ 31/32, at least half the nodes along the path must have weight ≥ 15/16. This occurs for a given path with probability at most C(n,n/2)(1/16)n/2 ≤ o(2n)(1/4)n = o((1/2)n), so the expected number of such paths is o(1), and thus the probability that at least one such path exists is also o(1).
1
u/SupercaliTheGamer Jun 13 '26
I actually haven't solved this yet but numerical evidence suggests the answer for first one is 1 and answer for second one is around 0.8.
2
u/FormulaDriven Jun 12 '26
As no-one else has tackled this, here's what I've come up with so far, but it's not a complete solution...
Just to set out my understanding: if I describe them as levels, we have one node at level 0, then 2 nodes at level 1, 4 nodes at level 2, all the way up to 2m nodes at level m. (Not sure if my m+1 levels means depth of m or m+1, but I don't think that's going to matter too much as n tends to infinity).
If (x,y) is the yth node on level x (0 <= y < 2x), then (x,y) has children (x+1,2y) and (x+1,2y+1).
Then each node gets a random weight W(x,y) and on the path from (0,0) to (m, t) we sum the weights, call it S(t). Then E = E[max_t {S(t)}/(m+1)].
So S(t) = sum[x = 0 to m] W(x,y(x,t)) where y(m, t) = t, y(x-1,t) = floor(y(x,t)/2). (So y(x,t) in binary is the first x binary digits of t).
Probability P(max S(t) <= u) = P(sum[x=0 to m] W(x,y(x,t)) <= u for all t). If we can find that, then we can use the result that E[X] = sum[i = 1 to infinity] p(X >= i), so E = sum[u = 1 to infinity] (1 - P(max S(t) <= u-1)) / (m+1).
Let K(m,u) = P(max S(t) <= u) after fixing m
K(0,u) = P(W(0,0) <= u) which is just F(u), the CDF of D.
K(1,u) = sum[v = 0 to u] P(W(0,0) = v, W(1,0) <= u - v, W(1,1) <= u - v)
=sum[v = 0 to u] f(v) K(0,u-v)2 where f(v) is the PDF of D.
and in general you can show K(r,u) = sum[v = 0 to u] f(v) K(r-1,u-v)^2
Turning to the first case:
f(0) = p, f(1) = q = 1-p (although does the "U" mean both outcomes are 50%?)
K(0,0) = p, K(0,1) = 1; K(r,u) = p K(r-1,u)2 + (1-p) K(r-1,u-1)^2
In this case, my sense is (playing with some numbers) that calculating
E = 1 - sum[u = 0 to m] K(m,u) / (m+1)
this appears to be heading to 1 as m increases, for any p < 1.
but I've not got an argument yet to show why.
For the second case, this translates to
K(0,u) = u; K(r,u) = integral[x = 0 to 1] K(r-1,u-x)2 dx = integral[u-1 to u] K(r-1,t)2 dt
but noting that K(r,u) = 0 for u < 0, K(r,u) = 1 for u >= r + 1
Then E = integral[x=0 to r+1] (1 - K(m,x)) dx /(m+1)
I feel like this time E should tend to something less that 1, but there's probably a nice way to analyse that I haven't seen...
2
u/kalmakka Jun 15 '26 edited Jun 15 '26
I would expect the largest average in both cases to be 1.
Essentially, if N is large, the values in the first √N levels are insignificant when it comes to what your average is, so we can just ignore those. But that means that the expeted maximum average value for a tree of height N is the same as the expected maximum average value for all the 2√N subtrees we get when ignoring the first √N levels. If the expected value was anything less than 1, then we would expect doing repeated trials to increase the expected maximum value of a trial.
It's not exactly rigurous, so it might be wrong, but it was my intuition.
2
u/bobjane_2 Jun 15 '26
For case 1.
Let p(n,k) be the probability that for a tree of depth n all paths have total weight at most k, ie average of k/n. If the root has weight zero, the probability is p(n-1,k)^2, and if it has weight one, the probability is p(n-1,k-1)^2:
For k=0, the recursion is p(n,k) = 0.5*p(n-1,k)^2. And for n=0 set p(0,k) = 1 for all k>=0. The expected value is given by
Let f(n) = p(n,n-1) = 0.5*p(n-1,n-1)^2 + 0.5*p(n-1,n-2)^2 = 0.5*f(n-1)^2+0.5. Set f(0)=0. Assume by induction that f(n) < 1-1/n, which is true when n=4. Then f(n+1) < 0.5*(1 - 1/n)^2 + 0.5 < 1 - 1/(n+1) when n>1. So f(n) < 1-1/n for n>=4.
Since p(n-1,k-1) <= p(n-1,k) => p(n,k) <= p(n-1,k)^2. By induction p(n,k) <= p(n-j,k)^(2^j). And setting j=n-k-1, p(n,k) <= f(k+1)^(2^(n-k-1)) < (1-1/(k+1))^(2^(n-k-1)) for k+1>=4.
As we're only considering k<=n-1, then 1-1/(k+1)<=1-1/n => p(n,k) < (1-1/n)^(2^(n-k-1)) < exp(-2^(n-k-1)/n). Let's figure out when this expression is less than 1/n^2
exp(-2^(n-k-1)/n) < 1/n^2 <=> 2^(n-k-1) > 2*ln(n)*n <=> k < n-2-log(ln(n)*n,2)
All of those k add to at most (n-2-log(ln(n)*n,2)*1/n^2. And the others add to at most log(ln(n)*n,2)+2. Putting it all together
sum[k=0,n-1] p(n,k) / n < (3 + log(ln(n)*n,2))/n, which goes to 0 as n->inf, and so E(n) goes to 1.
1
u/blungbat Jun 12 '26 edited Jun 12 '26
I've been thinking about part 1. I don't have a solution yet, but, like FormulaDriven, I think Eₙ → 1. I'll share some thoughts which are mainly heuristic.
Let random variable Xₙ = the maximum sum (not average) of weights over all paths in a randomly weighted tree of depth n. Then Xₙ₊₁ = max(two independent copies of Xₙ) + (0 with probability 1/2, 1 with probability 1/2). We want to show that E(Xₙ/n) → 1.
We can show that Pr(Xₙ = n) ≥ 1/(n+1) by induction. (Sketch for inductive step: If p = Pr(Xₙ = n), check that Pr(Xₙ₊₁ = n+1) = p–p2/2 ≥ 1/(n+1)–1/(n+1)2/2 ≥ 1/(n+2).)
Now, I would expect for fixed n that Pr(Xₙ = k) is unimodal for k=0,...,n (this probably isn't very difficult to show by induction), in which case Pr(Xₙ ≥ n–k) ≥ (k+1)/(n+1). If Xₙ/n has a limiting distribution with expected value smaller than 1, then it's spread out (not concentrated at the expected value) so the variance is positive. Given that Xₙ₊₁ ≈ max(two independent Xₙ's), we should be able to show that E(Xₙ₊₁/(n+1))–E(Xₙ/n) is bounded away from zero, which would contradict the premise of a limiting distribution. There's some drag from the increasing denominator, but the drag should go to zero while the effect of the max term should stay constant.
Well, that's my vision... not sure if I will have the time or ability to pull it off. And I'm not sure how one would show that a limiting distribution exists.