A path must end at a leaf
transcript
You hand a budget down a tree. At a leaf, nothing must be left. But what if you reach zero early? Many programs say true. They are wrong.
The root is five, with one child, four. The total to find is five. After the root, zero is left. But the root has a child, so it is not a leaf. The only path is five, four, which is nine. So the answer is false.
A second bug is in the base case. A missing child answers: is zero left? The root has no right child. Zero is left, so it answers true. A missing child is not a path. It must return false.
Check the total at a leaf only. A missing child is not a path. It returns false. Not whether zero is left.
A node with one child is not a leaf. A missing child is not a path. Full breakdown in the lecture.