Pandu M R
Pandu M R

Reputation: 21

Can a root node be considered as a leaf node if it has no child node?

My problem is to find how many leaf nodes there are in a given tree. I know how to count leaves of a tree but I am confused about whether or not the root node should be considered as a leaf node if there is no child to the root node?

Note: I have browsed on internet for the specific question but no one has given the answer to the my point. So I am asking here.

Upvotes: 1

Views: 1912

Answers (1)

somdutt
somdutt

Reputation: 1

By the general definition of the leaf nodes, yes. But root node is a special node of tree. root node can't be a leaf node irrespective of it has any child or not it will always be root node of tree.

Upvotes: 0

Related Questions