Amazon interview question

Coding tree functions