Trees grow downwards in computer science, and a root node is at the very top. The root of this tree is /photos
.
/photos
references to two other nodes: /safari
and /wedding
. /safari
and /wedding
are children or child nodes of /photos
.
Conversely, /photos
is a parent node because it has child nodes.
/safari
and /wedding
share the same parent node, which makes them siblings.
Note that the /safari
node is child (to /photos
) and parent (to lion.jpg
and giraffe.jpg
). It’s extremely common to have nodes act as both parent and child to different nodes within a tree.
When a node has no children, we refer to it as a leaf node.
Instructions
These terms: root, leaf, child, sibling, and parent give us a precise way to communicate the relationships between nodes.
What are the four leaf nodes in this diagram?
What node has no parent?
What is the sibling node to lion.jpg
?