UVa 122 - Trees on the level

Summary
Print the nodes of a completely specified binary tree in breadth-first order.

Explanation
Straight forward binary tree implementation.

Optimizations
None really needed. Even a linked nodes implementation is plenty fast enough to pass.

Gotchas
The definition of "completely specified" means that the number of input nodes equals the size of the tree. Duplicate values are permitted. Don't print any trailing spaces in your output.

Input
(11,LL) (7,LLL) (8,R) (5,) (4,L) (13,RL) (2,LLR) (1,RRR) (4,RR) (3,L) (4,R)

Output
5 4 8 11 13 4 7 2 1 not complete