Expected number of subtree removal in a tree.

755 Views Asked by At

I was solving this problem. In a gist the problem is as follows:

You are given a rooted tree. On each step you choose a node randomly and remove the subtree rooted by that node and the node itself, until all of them have been removed (that is root has been chosen). Find the expected number of steps in this process.

In the editorial it is written that the direct removal of the node $i$ (that node $i$ has been chosen, not its ancestors) is $\frac{1}{\text{Depth[i]}}$. Intuitively I realise that if some node has more ancestors then the probability that its ancestor is chosen (hence the node $i$ got removed) is more than the node itself. Hence, more ancestors implies lesser the probability of direct removal. But how the probability is exactly equal to $\frac{1}{\text{Depth[i]}}$, that I couldn't understand.

Please help.

1

There are 1 best solutions below

0
On

So if you assume that (I believe it is the case in this problem) every node is removed with an equal probability then for some particular node to be removed, one of its ancestors has to be chosen,

So number of ancestors of one particular node i = Depth [i]

Hence P(i is removed) = Depth[i] / Size of the tree

and P(i is chosen) = 1 / size of the tree

Hence P(i is chosen | i is removed) = 1/Depth[i]