Introduction to Binary Trees
Implement a binary tree structure with basic node insertion.
Input format
The first line contains level-order tokens representing the tree, where N denotes a null node.
Output format
Print level-order traversal of the tree, space-separated (nulls skipped).
Constraints
- Values fit in a 64-bit signed integer
- Trailing whitespace and a trailing newline are ignored by the judge
Read from stdin, write to stdout. Sample cases below show the exact format.
Sample cases
Example 1
Input
1 2 3 4 5 N 6Expected output
1 2 3 4 5 6Example 2
Input
1Expected output
1