-1

In the tree:

    A
   / \
  B   C <-- Difference = 2
 /   /
D   E
   /
  G

What are the two subtrees for node C that make it unbalanced??

Leslie Liang
  • 23
  • 3
  • 7

2 Answers2

0

Let's solve some homework Leslie...

The C tree has two subtrees. One of them isn't pictured...

     C
   /   \
  E
 /
G

Calculate the height of each subtree. Height 2 vs Height 0...

Ryan Ellis
  • 440
  • 2
  • 5
  • 18
  • Hi Ryan! Thanks for your response! – Leslie Liang Jul 13 '18 at 04:23
  • Then from what you said. That means for leaf nodes, they also have two subtrees, right? They have two nullptr for their left and right children right? I guess I just forgot that nullptr can be used as subtrees! Could you confirm what I said above was true? – Leslie Liang Jul 13 '18 at 04:24
0

Assuming your tree is a binary tree, each node in such tree has at max 2 nodes. While representing a tree if a child node is not explicitly drawn or mentioned, it is assumed to be null.

Thus the node C in your case has only one child node i.e. E and the other child is null.

vaibhavatul47
  • 2,766
  • 4
  • 29
  • 42