retagged by
55,030 views
159 159 votes
Let $T$ be a full binary tree with $8$ leaves. (A full binary tree has every level full.) Suppose two leaves $a$ and $b$ of $T$ are chosen uniformly and independently at random. The expected value of the distance between $a$ and $b$ in $T$ (ie., the number of edges in the unique path between $a$ and $b$) is (rounded off to $2$ decimal places) _________.

12 Answers

Best answer
205 205 votes

Two leaves a and b of T are chosen uniformly and independently at random.

See the word "independently" here. It means that choice of $a$ must not affect choice of $b$ and vice versa. This implies that both $a$ and $b$ can even be the same node.

Now, we are given that the binary tree has $8$ leaves. $\left(2^3 = 8\right) \implies$ we have $3$ levels in the tree starting from $0.$ The distance in terms of number of edges between any two leaf nodes will always be even. If we consider any two leaves (not necessarily distinct)

  • No. of pairs with path length $0 = 8.$ (When $a = b)$
  • No. of pairs with path length $2 = 8.$ (For each of the $8$ leaf nodes, we have a pair and since the selection is independent order of the pair is also significant)
  • No. of pairs with path length $4 = 16.$ (For each leaf node we have to go two levels up and while coming down we have $2$ choices. So, we get $8 \times 2 = 16$ pairs)
  • No. of pairs with path length $6 = 32.$ (For each leaf node we have to go till the root, and from there while coming down it has $2 \times 2 = 4$ choices. Thus we get $8 \times 4 = 32 $ pairs.

Total number of possible pairs $ = 8 \times 8 = 64$

So, expected path length

$\quad =0 \times \frac{8}{64}  + 2 \times \frac{8}{64}+4 \times \frac{16}{64}+6 \times \frac{32}{64}= \frac{272}{64}=4.25$

edited by
240 240 votes

A full binary tree of $8$ leaves

Let's say we take node $H.$ The distances from $H$ to all other nodes (including itself) would be:

$\begin{array}{|c|c|c|c|c|c|c|c|}\hline
H&I&J&K&L&M&N&O\\\hline
0&2&4&4&6&6&6&6\\\hline
\end{array}$

If another node is taken, a similar table (to the one above) is attained. Therefore, all nodes have the same distances when added together. 

So, if a node is considered, the probability of choosing another node would be $1/8$ (including itself - independent choosing]. 

Therefore, $E = \frac{1}{8} \left[0+2+4+4+6+6+6+6\right] = 4.25$

edited by
12 12 votes

Path can only have distinct vertices. If two leaves are same , path cannot be defined between them. distance(a,b) is not defined if a and b are same vertex.

This answer is according to definition of path given in two books which I came across:

1. Anaytics combinatorics by Alan Tucker

http://noahc.me/Applied%20Combinatorics%206th%20edition.pdf

page 4

2. Graph theory by Frank Harary.

https://shyam.nitk.ac.in/Books/GT%20Books/Harary.pdf page 13

3. mit book on discrete maths

https://courses.csail.mit.edu/6.042/spring17/mcs.pdf page 384-385

see the comment below by ahabnnc

 

 

edited by
7 7 votes
Ans should be 4.25,Becoz path length 0 is also possible as it is not said "distinct leafs"
edited by
6 6 votes
Choose any two leaves at random where first leaf is 'a' and second leaf 'b'. As it is mentioned 'independently' both the chosen leaves could be same and in that case path length = 0.

Now to find the expected path length, we have to

= $\frac{\sum\ pathLen\ *\ 8\ *\ pathsPerLeaf} {\sum TotalNoOfPaths} $

= $\frac{0*(8*1) + 1*0 + 2*(8*1) + 3*0 + 4*(8*2) + 5*0 + 6*(8*4)}{8*1+8*1+8*2+8*4}$

= 272/64 = 4.25
Answer:
Position:
Show:

Related questions

60 60 votes
7 answers 7 answers
37.5k
37.5k views
Arjun asked Feb 7, 2019
37,545 views
Consider the following statements:The smallest element in a max-heap is always at a leaf nodeThe second largest element in a max-heap is always a child of a root nodeA ma...
75 75 votes
6 answers 6 answers
47.5k
47.5k views
Arjun asked Feb 7, 2019
47,481 views
Consider the following four processes with arrival times (in milliseconds) and their length of CPU bursts (in milliseconds) as shown below:$$\begin{array}{|c|c|c|c|c|} \h...
39 39 votes
6 answers 6 answers
35.9k
35.9k views
Arjun asked Feb 7, 2019
35,877 views
The index node (inode) of a Unix -like file system has $12$ direct, one single-indirect and one double-indirect pointers. The disk block size is $4$ kB, and the disk bloc...
30 30 votes
5 answers 5 answers
25.8k
25.8k views
Arjun asked Feb 7, 2019
25,793 views
Consider the augmented grammar given below:$S’ \rightarrow S$$S \rightarrow \langle L \rangle \mid id$$L \rightarrow L, S \mid S$Let $I_0 = \text{CLOSURE} (\{[S’ \rightar...