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 .
$\begingroup$
$\endgroup$
7
-
$\begingroup$ I don’t understand your question at all. Perhaps you could give an example? $\endgroup$– Yuval FilmusCommented Oct 15, 2019 at 17:26
-
$\begingroup$ What do you mean by binomial trees? $\endgroup$– Marcelo FornetCommented 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$– graphicart86Commented 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$– Rick DeckerCommented Oct 15, 2019 at 23:44
-
$\begingroup$ @RickDecker - maybe OP means this: en.wikipedia.org/wiki/Binomial_heap $\endgroup$– HEKTOCommented Oct 16, 2019 at 14:30
|
Show 2 more comments
1 Answer
$\begingroup$
$\endgroup$
2
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.
-
$\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