eBay interview question

Tree and graph BFS problem