-1
$\begingroup$

Does anybody knows that how we can assign number to nodes for binomial tree . I mean how we can represent the number of nodes by array? please give me hint I am really confused .

$\endgroup$
7
  • $\begingroup$ I don’t understand your question at all. Perhaps you could give an example? $\endgroup$ Commented Oct 15, 2019 at 17:26
  • $\begingroup$ What do you mean by binomial trees? $\endgroup$ Commented Oct 15, 2019 at 18:33
  • $\begingroup$ I want to create a binomial tree then number its node and then represent the tree by array that array index represent the number that we have specified to node . $\endgroup$ Commented Oct 15, 2019 at 20:15
  • $\begingroup$ The problem here might be one of terminology: if you mean a tree for which every node has zero, one, or two children, many people refer to those as $binary$ trees. $\endgroup$ Commented Oct 15, 2019 at 23:44
  • $\begingroup$ @RickDecker - maybe OP means this: en.wikipedia.org/wiki/Binomial_heap $\endgroup$
    – HEKTO
    Commented Oct 16, 2019 at 14:30

1 Answer 1

0
$\begingroup$

In a binary tree, you can represent the tree from root to leaves as follows:

0 root 1 2 root's children 3 4 5 6 root's grandchildren etc.

To get the children of a node, you take its index x and compute 2x+1 and 2x+2.

This makes some certain assumptions: Each node has exactly two children, except the leaves, which are all on the same (or two neighboring) levels. If a level is not full, it is filled from left to right.

$\endgroup$
2
  • $\begingroup$ you mean representing of a binomial tree is by binary tree ? $\endgroup$ Commented Oct 16, 2019 at 12:41
  • $\begingroup$ I thought you meant binary tree. I don't know what you mean by binomial tree, sorry. $\endgroup$ Commented Oct 17, 2019 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.