Trimble interview question

Relating to Trees and Graphs