Tree position terminology/naming

Posted by wst on Programmers See other posts from Programmers or by wst
Published on 2013-10-31T20:38:14Z Indexed on 2013/10/31 22:17 UTC
Read the original article Hit count: 232

Filed under:
|
|

This is a naming things question. I am processing trees (XML documents), and there are often special rules applied to nodes based on structure. It's been very difficult coming up with concise naming conventions for some cases, namely for nodes in the first position among their siblings, along with some recursive relationship:

  1. Given an arbitrary node, I want to describe its first child, and then that node's first child, and so on recursively.

  2. Given another arbitrary node, I want to describe its parent if the parent is first among its siblings, and that parent's parent if it's first, and so on recursively.

Is there existing terminology to describe these tree positions? How would you name a variable or function that captures one of these cases so that it's intuitive to an unfamiliar developer trying to understand an algorithm?

© Programmers or respective owner

Related posts about naming

Related posts about Xml