Pergunta de entrevista da empresa UBS

Coding question on binary search tree .