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

   / \
  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.


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

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.

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

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