122 - Trees on the level

This problem requires you to design a somewhat cleaver data structure of binary tree.

You data structure has to be able to store an incomplete binary tree; so plain-old pointers would not suffice for this problem. Also, be careful of corner cases, like missing tree root.

A reference solution is here.

Creative Commons License
This blog by Che-Liang Chiou is licensed under a Creative Commons Attribution 4.0 International License.