What are the two subtrees for C that makes it unbalanced?

47 Views Asked by At

In the tree:

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

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

2

There are 2 best solutions below

2
Ryan Ellis On BEST ANSWER

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...

0
vaibhavatul47 On

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.