Google interview question

Coding exercise on sorting, tree