Check Full Binary Tree 07/26
A full binary tree is defined as a binary tree in which all nodes have either zero or two child nodes. Conversely, there is no node in a full binary tree, which has one child node. More information about full binary trees can be found here.
Full Binary Tree
1
/ \
2 3
/ \
4 5
Not a Full Binary Tree
1
/ \
2 3
/
4 Example
Given tree {1,2,3}, return true
Given tree {1,2,3,4}, return false
Given tree {1,2,3,4,5} return true用BFS 层序便利,如果遇到左右儿子有一个为空的,有一个不为空的,就返回false。利用了A^B,如果A是true,B是false,或者A是false,B是true,那么A^B就是true,A和B同时为true或者同时为false,则A^B为false
Last updated