I am not sure how to determine if a tree is balanced, perfectly balanced, or neither if I have it as a picture not a code
For example if I have this tree How can I check if it's balanced, perfectly balanced, or unbalanced? and can someone give me an example of a perfectly balanced tree?
[o]
/ \
[b] [p]
\ / \
[d] [m] [r]
Clearly I can tell that the tree is unbalanced if it was something like this:
[b]
\
[d]
\
[r]
\
[c]
However, if it was something very similar to the one above I don't know how to get it
This is a perfectly balanced and balanced tree:
[k]
/ \
[A] [p]
/ \
[N] [R]
Can someone please explain it to me?