0
$\begingroup$

I find the need to use an explicit level numbering for a tree. i.e. in the tree:

    A
   / \
  B   B
 /\   /\
C  C C  C

should I number the level C the 3rd and A as the first, or the opposite? As going 'up' the tree is going towards A; should the numbering reflect that as well? If can, please supply an authorized CS reference.

Thanks!

$\endgroup$
2
  • $\begingroup$ You don't say what you need the numbering for, so how can anyone say which numbering is "best"? $\endgroup$
    – Raphael
    Commented Nov 17, 2014 at 18:04
  • $\begingroup$ If there is no consensus on level numbering, this is a good answer as well. $\endgroup$
    – Jaaz
    Commented Nov 18, 2014 at 11:24

1 Answer 1

2
$\begingroup$

There's no such thing as "an authorized CS reference", since nobody has the authority to declare how tree levels should be numbered.

The "height" of a vertex is its distance from the root (or distance plus one; see another question about the definition) so it probably makes sense to start at the top in most cases. But you should use whichever numbering is most convenient in your situation.

$\endgroup$
2
  • $\begingroup$ Thank you, I noticed that question - but here it's a different matter. $\endgroup$
    – Jaaz
    Commented Nov 18, 2014 at 13:46
  • $\begingroup$ @user3675820 Yes, I linked that question because it's related, not because I think it gives the answer. $\endgroup$ Commented Nov 18, 2014 at 16:08

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