eBay Interview Question

Tree and graph BFS problem