Microsoft interview question

Tree and sorting questions