Learn
Trees are useful for modeling data that has a hierarchical relationship which moves in the direction from parent to child. No child node will have more than one parent.
To recap some terms:
root
: A node which has no parent. One per tree.parent
: A node which references other nodes.child
: Nodes referenced by other nodes.sibling
: Nodes which have the same parent.leaf
: Nodes which have no children.level
: The height or depth of the tree. Root nodes are at level 1, their children are at level 2, and so on.
Instructions
That was a lot of theory! Trees are beneficial and you’ll find they come up all the time as a useful way of modeling hierarchical data.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.