# Check if binary tree is full java

If there are no children, return true. If there are children, make sure there are two, and then check each of them recursively. By posting your answer, you agree to the privacy policy and terms of service.

Email Sign Up or sign in with Google. Check if a binary tree is full in Java? Aleksandr Podkutin 1, 1 12 Can you say your problem clearly? If the tree is complete, I will always get true. However, if it is incomplete sometimes I get true which is wrong and sometimes false. The first if condition is nor correct. So where is the leaf test? It's a good point. Better to put it as a comment on my answer though so someone looking at my answer would spot that.

Try to add return to each statement. JFPicard 3, 2 11 So, if the left is full, don't even look at the right? Your right, I've updated my anwser. So, hope this helps: All the algoritms [sic] above return true in this case - which this case? Given that the question explicates binary tree is full each node has 2 child nodes or none a commendable diligence , this tries to answer a different question.

Click the link 'complete binary tree' so you can see which case. If there are children, make sure there are two, and then check each of them recursively. By posting your answer, you agree to the privacy policy and terms of service. Email Sign Up or sign in with Google. Check if a binary tree is full in Java? Aleksandr Podkutin 1, 1 12 Can you say your problem clearly? If the tree is complete, I will always get true. However, if it is incomplete sometimes I get true which is wrong and sometimes false.

The first if condition is nor correct. So where is the leaf test? It's a good point. Better to put it as a comment on my answer though so someone looking at my answer would spot that. Try to add return to each statement. JFPicard 3, 2 11 So, if the left is full, don't even look at the right? Your right, I've updated my anwser. So, hope this helps: All the algoritms [sic] above return true in this case - which this case? Given that the question explicates binary tree is full each node has 2 child nodes or none a commendable diligence , this tries to answer a different question.

Click the link 'complete binary tree' so you can see which case. If you test those algoritms, they will return true, they shouldn't do that cause is not a full tree but a complete tree.