Amazon interview question

Create a tree and traverse it