Suppose you already have the basic binary procedures: empty (bt), root (bt), left (bt) and right (bt). Write an isLeaf (bt) procedure that returns true if the binary tree bt is a leaf node and false if it is not.
This is what I have:
proc isLeaf(bt) if (isEmpty(bt)) error('The binary tree is empty.'); elseif (left(bt) < right(bt)) return true; else return false;
Then write a procedure numLeaves (bt) that returns the number of leaves in the binary tree bt.
This is what I have:
proc numLeaves(bt) if (isEmpty(bt)) error ('The binary tree is empty.'); elseif (count left(bt) + right(bt)); return (left(bt) + right(bt);
Please, could you fix it?
source share