RATAN interview question

Tree,bfs