Implement a binary tree Node class. Each node stores a value and references to a left child and a right child. Children may be null when absent.
The constructor takes a value and two optional child references (defaulting to null) and assigns them to instance properties:
- val: the value stored at this node
- left: reference to the left child node, or null
- right: reference to the right child node, or null
Input
A single Node constructor call with a value and two child arguments.
Output
The constructor returns null (it produces an instance, not a value). The constructed node should expose the val, left, and right properties as set.
Examples
Example 1
Input["Node"]
[[0, 0, 0]]
Output[null]
Explanation: The constructor builds a Node whose val is 0, left is 0, and right is 0. The constructor itself returns null in the operation log.
Constraints
The class should accept three positional arguments: value, left, right.
Left and right should default to null when omitted.