4 ms·
A leaf is a node that has no children. So you don't need to represent it directly. Just check both children and if they are both None, it's a leaf. Empty tree
by super_mario 7y ago
A leaf is a node that has no children. So you don't need to represent it directly. Just check both children and if they are both None, it's a leaf.
Empty tree can be represented with root node that is a leaf and has no data.
- tom_mellior 7y agoYou forgot to include your Haskell code.
- super_mario 7y agoI'm talking about how you could do this in Python. Don't know much about Haskell.