Amazon Interview Question

Q: Question based on generic trees