What is meant by "the number of interior nodes in a binary tree having one child"?
Trees
Collapse
X
-
An interior node in a tree is a node that is not a leaf node. (sometimes the rootOriginally posted by mia023What is meant by "the number of interior nodes in a binary tree having one child"?
node isn't considered an interior node either but the meaning differs here).
kind regards,
Jos -
if I want to desgin an algorithm that checks if the interior node has one child or not should I do the following:Originally posted by JosAHAn interior node in a tree is a node that is not a leaf node. (sometimes the root
node isn't considered an interior node either but the meaning differs here).
kind regards,
Jos
Use the preoder traversal and check if the node has either a left and a right
Is that correct???Comment
-
You have to check two definitions:Originally posted by mia023if I want to desgin an algorithm that checks if the interior node has one child or not should I do the following:
Use the preoder traversal and check if the node has either a left and a right
Is that correct???
1) a node must have one single child;
2) that child must be a leaf node.
You are supposed to count all the nodes that comply with the following definitions.
It doesn't matter how you count them, i.e. simply recurse down your tree and
test all the nodes.
kind regards,
JosComment
Comment