UBS interview question

Binary tree algorithm