随机生成的树的预期深度是多少?


19

我很早以前就考虑过这个问题,但是对此一无所知。

生成算法如下。我们假设有n离散的节点,编号从到。然后,每个在我们使在树个节点的母公司是在随机节点。依次遍历每个,以使结果成为根节点为的随机树。(也许这不够随机,但这无关紧要。)n − 1 i { 1 ,… ,n − 1 } i { 0 ,… ,i − 1 } i 00n−1i{1,…,n−1}i{0,…,i−1}i0

这棵树的预期深度是多少?


我认为v0是根,你的意思是说:“那对于每个i在[1,n),我们做了i个节点的父......”。对?
— 无题

你尝试了什么?您是否尝试过编写递归关系,比如说d(i),即节点的预期深度i?
— DW

3
这些对象被称为“随机递归树”。
— 詹姆斯·马丁

Answers:


15

我认为关于有一个集中的结果elog⁡n,但是我还没有填写细节。

我们可以得到一个上限值,该节点的概率具有d的祖先不包括0。对于每个可能的完整链d非零祖先(一个1,一个2,。。。,一d),该链的概率为(1nd0d(a1,a2,...,ad)。对应于1(1a1)(1a2)⋯(1ad)×1n(1+1项的 n次1n项按顺序排列。因此,此概率的上限为1(1+12+13+⋯1n−1)d其中Hn-1是n-1次谐波数1+11n(d!)Hn−1dHn−1n−1。ħñ-1个≈日志(ñ-1)+γ。对于固定d和Ñ→交通∞,则概率节点Ñ是在深度d+1为至多1+12+...+1n−1Hn−1≈log⁡(n−1)+γdn→∞nd+1

(log⁡n)dn(d!)(1+o(1))

通过斯特林的近似,我们可以估计为

1n2πd(elog⁡nd)d.

对于大的,任何大于e log n的东西,指数的底数都很小,因此该范围很小,我们可以使用联合范围来表示存在至少一个带有d个非零祖先的节点的概率为小。delog⁡nd


看到

Luc Devroye,Omar Fawzi,Nicolas Fraiman。“缩放附件随机递归树的深度属性。”

B.皮特尔。请注意随机递归树和随机mary搜索树的高度。随机结构和算法,5:337-348,1994年。

前者声称后者以最大概率显示最大深度为,并提供了另一种证明。(e+o(1))log⁡n


2
非常好。为了向其他读者阐明:由于您无法重复,因此术语(1 + 1ai只是一个上限。(1+12+…+1n−1)d
— 彼得·索尔

3

几年前回答了这个问题,但是,只是为了好玩,这里只是上限的简单证明。我们给期望设定一个界限,然后是一个尾限。

定义RV 要的节点深度我∈ { 0 ,1 ,... ,ñ - 1 }。定义ϕ i = ∑ i j = 0 e d j。dii∈{0,1,…,n−1}ϕi=∑j=0iedj.

引理1. 预期的最大深度最多为eE[maxidi]。eHn−1

证明。最大深度最大为ln⁡ϕn−1。要完成我们展示。E[ln⁡ϕn−1]≤eHn−1

对于任何,调理上φ 我- 1,通过检查φ 我, ë [ φ 我i≥1ϕi−1ϕi

E[ϕi|ϕi−1]=ϕi−1+E[edi]=ϕi−1+eiϕi−1=(1+ei)ϕi−1.

通过归纳法得出

E[ϕn−1]=∏i=1n−1(1+ei)<∏i=1n−1exp⁡(ei)=exp⁡(eHn−1).

So, by the concavity of the logarithm,

E[ln⁡ϕn−1]≤ln⁡E[ϕn−1]<ln⁡exp⁡(eHn−1)=eHn−1.       ◻

Here is the tail bound:

lemma 2. Fix any c≥0. Then Pr[maxidi]≥eHn−1+c is at most exp⁡(−c).

Proof. By inspection of ϕ, and the Markov bound, the probability in question is at most

Pr[ϕn−1≥exp⁡(eHn−1+c)]≤E[ϕn−1]exp⁡(eHn−1+c).
From the proof of Lemma 1, E[ϕn−1]≤exp⁡(eHn−1). Substituting this into the right-hand side above completes the proof.   ◻

As for a lower bound, I think a lower bound of (e−1)Hn−O(1) follows pretty easily by considering maxidi≥ln⁡ϕt−ln⁡n. But... [EDIT: spoke too soon]

It doesn't seem so easy to show the tight lower bound, of (1−o(1))eHn...


2

I have actually thought about the same question (although in a completely different formulation) a few months ago, as well as some close variants.

I don't have a closed form (/ asymptotic) solution for it, but you might find this view useful (are you only looking for upper bound perhaps?).

The process you describe here is a generalization of the Chinese Restaurant Process, where each "table" is a subtree whose root's parent is v0.

This also gives us a recursion formula for your question.

Denote by h(n) the expected heights of a such tree process with n nodes.

Denote by Pn(B)=Πb∈B(b−1)!n! (the probability of distribution B of the nodes into subtrees).

Then the quantity you're looking for, h(n), is given by:

h(n)=∑B∈BnPn(B)⋅maxb∈Bh(b)

If you wish to code this recursion, make sure you use the following so it won't go into infinite loop:

h(n)=∑B∈Bn∖{{n}}Pn(B)⋅maxb∈Bh(b)1−1n!

Where Bn is the set of all partitions of n identical balls into any number of non-empty bins, and h(1)=1.


In practice, when I needed this I just used a simple monte-carlo method for estimating h(n), as trying to actually compute h by this method is extremely inefficient.


1
Thanks for the idea! Actually I wrote a monte-carlo program the first time when I met with this problem, but to my surprise the accurate result is so difficult to get.
— zhxchen17
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.