YANDEX interview question

Algorithms on graphs and binary trees