#K67312. Check Full Binary Tree

    ID: 32615 Type: Default 1000ms 256MiB

Check Full Binary Tree

Check Full Binary Tree

Given a binary tree, determine whether it is a full binary tree.

A full binary tree is defined as a binary tree in which every node has either 0 or 2 children. In other words, for every node \(n\) in the tree, the number of children is either \(0\) (if it is a leaf) or \(2\) (if it is an internal node). Formally, if we denote the number of children of node \(n\) as \(\deg(n)\), then a binary tree is full if \(\forall n, \ \deg(n) \in \{0,2\}\).

Your task is to implement a function that checks whether a given binary tree is full. The binary tree is provided in a level-order traversal format where missing nodes are denoted by the string "null".

inputFormat

The input consists of a single line containing space-separated tokens representing the nodes of the binary tree in level-order traversal. Each token is either an integer (the value of the node) or "null" indicating that the node is absent. For example:

1 2 3 4 5

represents the following binary tree:

    1
   / \
  2   3
 / \
4   5

An input of "null" represents an empty tree.

outputFormat

Output a single line: "True" if the binary tree is a full binary tree, and "False" otherwise.

## sample
1 2 3 4 5
True