Amazon Interview Question

Create a tree and traverse it