Pergunta

Let $C_h$ be the number of possible heaps for the set of keys $\{1,...,2^h-1\}$. Determine a recurrence relation for $C_h$ via the substitution method and prove it.

Definition

A binary tree is ordered if the key at every node is smaller than the keys at its children.

An ordered binary tree of height $h$ is called a heap if the tree induced by all levels except the last is a complete binary tree and all leaves are "as much to the left as possible".

So what I've come up with is this expression:

$$C_h=\displaystyle\prod_{n=1}^{h} (2^{i-1})!$$

The intuition behind it is that with every increment by $1$ of $h$ the tree gains $2$ times more leaves than before and the possibilities of ordering these leaves can be determined via the factorial operation. Does that make sense?

Nenhuma solução correta

Licenciado em: CC-BY-SA com atribuição
Não afiliado a cs.stackexchange
scroll top