Hey guys - so not a programming problem here, but one that I just can't seem to figure out.
In my notes, it says,
A binary tree of depth d is almost complete if:
1)Each leaf in the tree is either at level d or at d-1
2)For any node n in the tree with a right descendant at level d,
all the left descendant of n that are leaves are also at level d.
Here are two examples:
The first one, according to my notes, is not almost complete because: "Since A has a right descendant J at level 3, but it has a left descendant E that is a leaf at level 2"
I think that makes sense.
However, for the second one...we didn't get an answer. But, from what I can tell, we have a right descendant F at level 2, and at least all the leaves on the left are at level 2 - so that would be an almost complete binary tree.
Am I even thinking straight here? Finals week...brain's almost fried.
Thanks,
Josh