**Problem Detail:**

I'm researching the topic of succinct tree representations right now and came across this presentation. On slide 17 there is an example of heap-like notation of a BST (using BFT bit-vectors) and the author claims that the amount of bits needed to represent a tree of $n$ elements (without their values) is exactly $2n+1$.

According to my calculations, it's $2n-1$. Here they are:

- As in this representation every BST is represented as a complete tree, for the complete tree of height $k$ it has $2^{k+1}-1$ nodes.
- On average for $n$ nodes tree has a height of $log_2n$.
- Replacing the $k$ from the first list item with the average BST height from the second list item I received:

$$2^{log_2n+1}-1=2n-1$$

What am I missing in my calculations? Where do these 2 extra bits come from?

Thanks in advance for your answer!

###### Asked By : ddnomad

###### Answered By : Pratik Deoghare

You can count it like this:

Let $n$ be the original number of nodes

Each original node has 2 children after adding the external nodes.

So 1 bit for the original node and 2 for its children. Total $3n$ bits.

But we are over counting here because original node is child of one other original node. So we subtract $n$ and get $2n$.

But we over corrected the count because root node has no parent so we add back 1 bit.

$2n + 1$.

Question Source : http://cs.stackexchange.com/questions/64367

**3200 people like this**

## 0 comments:

## Post a Comment

Let us know your responses and feedback