UCL-INGI / LEPL1402

INGInious tasks for LEPL1402 at EPL ( UCLouvain )
4 stars 5 forks source link

Module 5: FTree is incorrect #37

Open xgillard opened 3 years ago

xgillard commented 3 years ago

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).