Cognizant Interview Question

Construct and traverse the tree