Naming
Universally, names of classes are written in PascalCase
, and you should really stick to it, even if the compiler does not enforce it:
binary_tree -> BinaryTree
get
ters
Getters are highly frowned upon in Python. Values are generally accessed directly.
If you really do not want the user to access values directly you may make them "private" by prefixing __
and letting a @property
return them.
Decide for your nil
values
None
is the standard nil
(nothing) value in Python but in get_right_height
you return -1 if the value isNone
. If so just make the default -1
and remove the getter as suggested above.
Repetition Repetition
You repeat b.add
6 times, use a loop to avoid such waste.