Microsoft interview question

to implement a bfs style question