github.com/benz9527/toy-box/algo@v0.0.0-20240221120937-66c0c6bd5abd/tree/full_binary_tree.go (about) 1 package tree 2 3 func CreateNodeWithItem(item int) *Node { 4 return &Node{Item: item} 5 } 6 7 func FullBinaryTreeNodeValidate(n *Node) bool { 8 if n == nil { 9 return true 10 } 11 12 if n.Left == nil && n.Right == nil { 13 return true 14 } 15 16 if n.Left != nil && n.Right != nil { 17 return FullBinaryTreeNodeValidate(n.Left) && FullBinaryTreeNodeValidate(n.Right) 18 } 19 20 return false 21 } 22 23 func IsFullBinaryTree(bt *BinaryTree) bool { 24 if bt == nil { 25 return true 26 } 27 28 return FullBinaryTreeNodeValidate(bt.Root) 29 }