Can a tree node be both a root node and leaf node? If so, why?
I understand that the root node is at Level 0 of the tree. I also understand that a leaf node is a tree node that has no children. So if a tree has a root node A and nothing else, would that root node A also be considered a leaf node?
Is it possible for a tree node to be both a root node and leaf node?
From this Wikipedia link on Tree Data Structures, section Terminologies used in Trees:
So by definition, if a Tree structure only consists of a single Node, that single Node will in fact be both a Root and a Leaf. Read the link for further detail.
Now, whether your professor considers this to be correct is a whole 'nother story.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With