I'm reading up on Binary Search Trees and I have a question to answer similar to Ordered Binary Tree of Strings
Are the trees I've drawn below correct for before and after balancing? The data being entered are the strings, in order of, Mercury, Venus, Earth, Mars, Jupiter, Saturn, Uranus
Before balancing:
Mercury
/ \
Earth Venus
\ /
Mars Saturn
/ \
Jupiter Uranus
After balancing:
Mercury
/ \
Jupiter Uranus
/ \ / \
Earth Mars Saturn Venus
Is it also correct that the depth of the first tree is 3 and the depth of the second tree is 2, and that the maximum size is 7 (based on n = 2^(d+1)-1
where d
= depth?