This issue relates to #35 (should probably be a subtask of it).
The FTree expects a depth of 0 for leaves. This is not correct as a leaf is a (sub)tree comprising one single node. Therefore, it has a depth 1.
Also, rather than relying on left() == null && right() == null it would be better if all nodes implemented an isLeaf() method. That way, leaves could be a Tree implementation totally separated from the Node class. This would be way more functional (akin to the Nil in functional lists).
This issue relates to #35 (should probably be a subtask of it).
The FTree expects a depth of 0 for leaves. This is not correct as a leaf is a (sub)tree comprising one single node. Therefore, it has a depth 1.
Also, rather than relying on
left() == null && right() == null
it would be better if all nodes implemented anisLeaf()
method. That way, leaves could be aTree
implementation totally separated from theNode
class. This would be way more functional (akin to theNil
in functional lists).