Amazon interview question

Question 1 was based on tree traversal