I need a tree structure that works roughly like the following
for each new child I need to match it (with some criteria) with a parent from the previous level only
when the tree is completely initialized, for each leaf I need to find the first
parentancestor that has siblings, i.e. the node just after the branching point.
While the latter is pretty easy with a tipical tree structure, for the first I'd like to just access all nodes of a layer without traversing the whole tree (even with BFS). Does this have a name?
I'm thinking to just keep track of level number for each node and build a second structure to represent levels.
child
, there should be exactly oneparent
, which should be known/well-defined on insertion(new
): are you talking about potential parents to select from?First parent
might be first ancestor. $\endgroup$ancestor
$\endgroup$